Skip to content

Commit

Permalink
Merge pull request #23 from 21TORR/fix-otf-support
Browse files Browse the repository at this point in the history
Add proper support for `opentype` (`.otf`) fonts in `declare-font`.
  • Loading branch information
apfelbox authored Apr 25, 2022
2 parents 7d82798 + fd6f285 commit 5599317
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
0.7.2
=====

* (improvement) Add proper support for `opentype` (`.otf`) fonts in `declare-font`.


0.7.1
=====

Expand Down
11 changes: 10 additions & 1 deletion mixins/font.scss
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@
/// @param {String[]} $font-styles The supported font styles
/// @param {String[]} $types The supported file types
///
$font-type-file-extension-map: (
opentype: "otf",
);

@mixin declare-font (
$relative-path,
$font-family,
Expand All @@ -92,7 +96,12 @@
$src : ();

@each $type in $types {
$src: list.append($src, url("#{$relative-path}-#{$font-weight}-#{$font-style}.#{$type}") format("#{$type}"), comma);
$file-extension: $type;

@if (map.has-key($font-type-file-extension-map, $type)) {
$file-extension: map.get($font-type-file-extension-map, $type);
}
$src: list.append($src, url("#{$relative-path}-#{$font-weight}-#{$font-style}.#{$file-extension}") format("#{$type}"), comma);
}

font-family: $font-family;
Expand Down

0 comments on commit 5599317

Please sign in to comment.