summaryrefslogtreecommitdiffstats
path: root/debian/missing-sources/bourbon/app/assets/stylesheets/helpers/_font-source-declaration.scss
blob: 18b381e697d3cbbe68541760b1d01ec0956db692 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// Used for creating the source string for fonts using @font-face
// Reference: http://goo.gl/Ru1bKP

@function font-url-prefixer($asset-pipeline) {
  @if $output-bourbon-deprecation-warnings == true {
    @warn "[Bourbon] [Deprecation] `font-url-prefixer` is deprecated and " +
    "will be removed in 5.0.0.";
  }

  @if $asset-pipeline == true {
    @return font-url;
  } @else {
    @return url;
  }
}

@function font-source-declaration(
  $font-family,
  $file-path,
  $asset-pipeline,
  $file-formats,
  $font-url) {

  @if $output-bourbon-deprecation-warnings == true {
    @warn "[Bourbon] [Deprecation] `font-source-declaration` is deprecated " +
    "and will be removed in 5.0.0.";
  }

  $src: ();

  $formats-map: (
    eot:   "#{$file-path}.eot?#iefix" format("embedded-opentype"),
    woff2: "#{$file-path}.woff2" format("woff2"),
    woff:  "#{$file-path}.woff" format("woff"),
    ttf:   "#{$file-path}.ttf" format("truetype"),
    svg:   "#{$file-path}.svg##{$font-family}" format("svg")
  );

  @each $key, $values in $formats-map {
    @if contains($file-formats, $key) {
      $file-path: nth($values, 1);
      $font-format: nth($values, 2);

      @if $asset-pipeline == true {
        $src: append($src, font-url($file-path) $font-format, comma);
      } @else {
        $src: append($src, url($file-path) $font-format, comma);
      }
    }
  }

  @return $src;
}