Skip to content
Snippets Groups Projects
Commit 88988922 authored by Arnaud Levy's avatar Arnaud Levy
Browse files

font-face util

parent 75d0219e
No related branches found
No related tags found
No related merge requests found
......@@ -279,4 +279,29 @@
.description
margin-top: 0
width: col(8)
margin-left: $grid-gutter
\ No newline at end of file
margin-left: $grid-gutter
// https://gist.github.com/jonathantneal/d0460e5c2d5d7f9bc5e6
@function str-replace($string, $search, $replace: "")
$index: str-index($string, $search)
@if $index
@return str-slice($string, 1, $index - 1) + $replace + str-replace(str-slice($string, $index + str-length($search)), $search, $replace);
@return $string
@mixin font-face($name, $path, $weight: null, $style: null, $exts: (eot woff2 woff ttf svg))
$src: null
$extmods: (eot:"?", svg:"#" + str-replace($name," ","_"))
$formats: (otf: "opentype", ttf: "truetype")
@each $ext in $exts
$extmod: if(map-has-key($extmods, $ext), $ext + map-get($extmods, $ext), $ext)
$format: if(map-has-key($formats, $ext), map-get($formats, $ext), $ext)
$src: append($src, url(quote("/assets/fonts/" + $path + "." + $extmod)) format(quote($format)), comma,)
@font-face
font-family: quote($name)
font-style: $style
font-weight: $weight
font-display: swap
src: $src
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment