Created
July 26, 2021 05:50
-
-
Save kezzbracey/32e02576469e220559f7494be54c8026 to your computer and use it in GitHub Desktop.
Font face boilerplate
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
/* | |
CSS for the normal weight and style file for a custom font. | |
Attempts to load the file locally first. | |
Use the line that loads a woff2 version of the font if you have the required file, | |
or else delete that line and just use the woff file loading line. | |
Uses font-display:swap; to help the loading process. | |
*/ | |
@font-face { | |
font-family: 'Custom Font'; | |
src: local('Custom Font'), | |
url('/webfont/custom-font-regular.woff2') format('woff2'), | |
url('/webfont/custom-font-regular.woff') format('woff'); | |
font-weight: normal; | |
font-style: normal; | |
font-display: swap; | |
} | |
/* | |
Include an additional @font-face block for each font file in the family. | |
Change the font-weight and font-style value to match each font file | |
*/ | |
@font-face { | |
font-family: 'Custom Font'; | |
src: local('Custom Font'), | |
url('/webfont/custom-font-bold.woff2') format('woff2'), | |
url('/webfont/custom-font-bold.woff') format('woff'); | |
font-weight: bold; | |
font-style: normal; | |
font-display: swap; | |
} | |
@font-face { | |
font-family: 'Custom Font'; | |
src: local('Custom Font'), | |
url('/webfont/custom-font-italic.woff2') format('woff2'), | |
url('/webfont/custom-font-italic.woff') format('woff'); | |
font-weight: normal; | |
font-style: italic; | |
font-display: swap; | |
} | |
/* | |
When using the custom font in CSS, strongly recommend creating a font stack with at least one fallback specified. | |
*/ | |
.myclass { | |
font-family: 'Custom Font', Arial, sans-serif; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment