Last active
July 22, 2023 14:03
-
-
Save nikitadmitr/0e5c1b102273ab4895b3f84dd5ea4b3d to your computer and use it in GitHub Desktop.
font-adding-algorithm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$path-to-fonts: '../fonts'; | |
$font-families: ( | |
'FontName1': ((100, 'Thin'), | |
(200, 'ExtraLight'), | |
(300, 'Light'), | |
(400, 'Regular'), | |
(500, 'Medium'), | |
(600, 'SemiBold'), | |
(700, 'Bold'), | |
(800, 'ExtraBold'), | |
(900, 'Black')), | |
'FontName2': ((100, 'Thin'), | |
(200, 'ExtraLight'), | |
(300, 'Light'), | |
(400, 'Regular'), | |
(500, 'Medium'), | |
(600, 'SemiBold'), | |
(700, 'Bold'), | |
(800, 'ExtraBold'), | |
(900, 'Black')), | |
'FontName3': ((100, 'Thin'), | |
(200, 'ExtraLight'), | |
(300, 'Light'), | |
(400, 'Regular'), | |
(500, 'Medium'), | |
(600, 'SemiBold'), | |
(700, 'Bold'), | |
(800, 'ExtraBold'), | |
(900, 'Black')) | |
); | |
@each $font-family, | |
$weights in $font-families { | |
@each $weight in $weights { | |
$weight-number: nth($weight, 1); | |
$weight-name: nth($weight, 2); | |
@font-face { | |
font-family: $font-family; | |
font-style: normal; | |
font-weight: $weight-number; | |
src: url('#{$path-to-fonts}/#{$font-family}/#{$font-family}-#{$weight-name}.ttf') format('truetype'); | |
} | |
@font-face { | |
font-family: $font-family; | |
font-style: italic; | |
font-weight: $weight-number; | |
src: url('#{$path-to-fonts}/#{$font-family}/#{$font-family}-#{$weight-name}Italic.ttf') format('truetype'); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can read about here