Last active
June 30, 2016 09:10
-
-
Save JodiWarren/574247831bfad0eb0e3600f1be25a28a to your computer and use it in GitHub Desktop.
Quick and easy mixin for adding new fonts in a consistent manner.
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
| //// | |
| /// @author Jodi Warren for JH | |
| /// @group _fonts | |
| //// | |
| /// Add a new @font-face font with consistent markup. All file types should | |
| /// be provided with the same file name, obviously bar the extension. | |
| /// If you wish to use multiple weights/styles of the same font family, simply | |
| /// provide them with the same family name, and specify the weight and style. | |
| /// | |
| /// @example @include addFont('Gill Sans', '../fonts/gill-sans/gill-sans-regular', 400, normal); | |
| /// | |
| /// @param $family {string} The font family name that you wish to use in CSS. | |
| /// @param $pathWithoutFileType {string} The path to the file. | |
| /// @param $weight {number} The CSS weight of this font file. | |
| /// @param $style {string} The style of this font file. Should be normal, italic, or oblique. | |
| /// | |
| /// @output A @font-face block | |
| @mixin addFont($family, $pathWithoutFileType, $weight: 400, $style: normal) { | |
| @font-face { | |
| font-family: $family; | |
| src: url('#{$pathWithoutFileType}.eot'); | |
| src: url('#{$pathWithoutFileType}.eot?#iefix') format('embedded-opentype'), url('#{$pathWithoutFileType}.woff2') format('woff2'), url('#{$pathWithoutFileType}.woff') format('woff'), url('#{$pathWithoutFileType}.ttf') format('truetype'); | |
| font-style: $style; | |
| font-weight: $weight; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment