@function main-src($formats, $file-path, $font-family) {
  // Return the list of `src` values, in order, that
  // a good `@font-face` will need, including only
  // those formats specified in the list `$formats`.
  $result: ();
  @if index($formats, eot) {
    $eot-val: url('#{$file-path}.eot?#iefix') format('embedded-opentype');
    $result: append($result, $eot-val, comma);
  }
  @if index($formats, woff2) {
    $woff2-val: url('#{$file-path}.woff2') format('woff2');
    $result: append($result, $woff2-val, comma);
  }
  @if index($formats, woff) {
    $woff-val: url('#{$file-path}.woff') format('woff');
    $result: append($result, $woff-val, comma);
  }
  @if index($formats, ttf) {
    $ttf-val: url('#{$file-path}.ttf') format('truetype');
    $result: append($result, $ttf-val, comma);
  }
  @if index($formats, svg) {
    $svg-val: url('#{$file-path}.svg##{$font-family}') format('svg');
    $result: append($result, $svg-val, comma);
  }
  @return $result;
}

@mixin scut-font-face (
  $font-family,
  $file-path,
  $weight: normal,
  $style: normal,
  $formats: eot woff2 woff ttf svg
) {

  @if index('italic' 'oblique', $weight) {
    $style: $weight;
    $weight: normal;
  }

  @font-face {
    font-family: $font-family;
    font-weight: $weight;
    font-style: $style;

    @if index($formats, eot) {
      src: url('#{$file-path}.eot');
    }
    src: main-src($formats, $file-path, $font-family);
  }

}
