Created
April 7, 2021 16:15
-
-
Save lilpolymath/8a4c3acfcc6dac0db4ae1e1024dea985 to your computer and use it in GitHub Desktop.
SCSS mixin to load fonts.
This file contains hidden or 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
@mixin font($font-family, $font-file, $font-weight) { | |
@font-face { | |
font-family: $font-family; | |
// Add font types here | |
src: url($font-file+'.ttf') format('truetype'); | |
font-weight: $font-weight; | |
font-style: normal; | |
font-display: swap; | |
} | |
} | |
// Alias import with gatsby-plugin-alias-import | |
@include font('Open Sauce Sans', '@fonts/OpenSauceSans-Bold', 700); | |
@include font('Open Sauce Sans', '@fonts/OpenSauceSans-Medium', 500); | |
@include font('Open Sauce Sans', '@fonts/OpenSauceSans-Regular', 400); | |
@include font('Open Sauce Sans', '@fonts/OpenSauceSans-SemiBold', 600); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment