
@mixin font-variable-include(
	$name,
	$file,
	$weight-range: 200 700,
	$path: $base-font-path
) {
	@font-face {
		src: url('#{$path}/#{$file}.woff2') format("woff-variations");
		font-weight: $weight-range;
		font-family: $name;
	}
}

// Check the font and load them.
@mixin font-variable-load($font) {
	//
	// Define scoped variables
	$load: false;
	$font-name: '';
	$font-path: $base-font-path !default;
	$family: '';

	//
	// Check if the variable is a map
	// if it's not a map, its not a font to include.
	@if type-of($font) == 'map' {
		//
		// Check if the include has a font-family;
		@if map-has-key($font, 'font-family') == false {
			@warn "Your included font doesn't have a specified 'font-family'";
		} @else {
			//
			// Check if the font if it needs to load, has weights to include.
			@if map-has-key($font, 'load') {
				@if map-get($font, 'load') == true {
					@if map-has-key($font, 'weight-range') == false {
						@warn "You are trying to include a font without weight range, please specify the weight-range to load.";
					} @else {
						$load: true;
					}
				}
			}
			// Check if a font path has been set, if so, override the default;
			@if map-has-key($font, 'path') {
				$font-path: map-get($font, 'path');
			}
			
			// Check if a font files have been set
			@if map-has-key($font, 'files') {
				$font-files: map-get($font, 'files');
			}

			// Load the fonts if true
			@if $load {
				@include font-variable-include(
					convertToFontname($font),
					convertToFontname($font, true),
					map-get($font, weight-range),
					$font-path
				);
			}

			// Set use
			@if map-has-key($font, 'use') {
				@include font-use(map-get($font, 'use'), map-get($font, 'font-family'));
			}
		}
	}
}
