-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
_font.scss
207 lines (189 loc) · 5.13 KB
/
_font.scss
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
/* stylelint-disable media-feature-name-no-vendor-prefix */
@use 'sass:list';
@use 'sass:map';
@use 'sass:string';
@use '../functions';
/// Font Smoothing
/// @group Typo
/// @author Felix Scholze
/// @link https://nickbulljs.medium.com/3-css-font-properties-you-need-to-use-in-2020-1e60c415b8a8
/// @since v1.0.0
@mixin font-smoothing {
-moz-osx-font-smoothing: grayscale; // Firefox
@media
screen and (-webkit-min-device-pixel-ratio: 2),
screen and (resolution >= 192dpi),
screen and (resolution >= 2dppx) {
-webkit-font-smoothing: antialiased; // Safari | Best of Retina displays
}
@media
not screen and (-webkit-min-device-pixel-ratio: 2),
not screen and (resolution >= 192dpi),
not screen and (resolution >= 2dppx) {
-webkit-font-smoothing: subpixel-antialiased; // Best for non Retina displays
}
}
/* stylelint-disable function-url-quotes */
/// Adds fonts with the original @font-face rule
/// Attention!
/// When you use Laravel Mix your fonts path begins at the mix.config file location
///
/// @param {String} $name Font-Name
/// @param {String} $path Path to font
/// @param {Number} $weight [null] Font-Weight
/// @param {String} $style [null] Font-Style
/// @param {List} $exts [eot woff2 woff ttf svg] Font-Formats to add
/// @group Typo
/// @author Jonathan Neal extended by Felix Scholze
/// @link https://gist.github.com/jonathantneal/d0460e5c2d5d7f9bc5e6
/// @since v1.0.0
/// @deprecated font-face-old is deprecated!.
///
/// @example
/// @include font-face(
/// 'Open Sans',
/// '#{$path-to-fonts}/opensans/Light/OpenSans-Light',
/// 300,
/// normal,
/// woff2 woff
/// );
///
@mixin font-face-old(
$name,
$path,
$weight: null,
$style: null,
$exts: eot woff2 woff ttf svg,
$display: swap
) {
$src: null;
$extmods: (
'eot': '?iefix',
'svg': '#' + functions.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: list.append($src, url(string.quote($path + '.' + $extmod)) format(string.quote($format)), comma);
}
@font-face {
font-weight: $weight;
font-style: $style;
font-family: string.quote($name);
font-display: $display;
@if list.index($exts, 'eot') {
src: local($name), url($path + '.eot'), $src;
} @else {
src: local($name), $src;
}
}
}
/* stylelint-enable function-url-quotes */
/// Responsive And Fluid Typography With vh And vw Units
/// @param {Number} $font-unit [rem]
/// @param {Number} $min-font-size [14]
/// @param {Number} $max-font-size [20]
/// @param {Number} $min-screen-size [400]
/// @param {Number} $max-screen-size [980]
/// @group Typo
/// @author Michael Riethmuller
/// @link https://www.smashingmagazine.com/2016/05/fluid-typography/
/// @deprecated fluid-typo is deprecated!.
@mixin fluid-typo(
$font-unit: rem,
$min-font-size: 14,
$max-font-size: 20,
$min-screen-size: 400,
$max-screen-size: 980
) {
@error 'fluid-typo is deprecated.';
/* stylelint-disable */
font-size: calc(
#{$min-font-size}#{$font-unit} + (#{$max-font-size} - #{$min-font-size}) * (
100vw - #{$min-screen-size}px
) / (#{$max-screen-size} - #{$min-screen-size})
);
/* stylelint-enable */
}
/// Adds font-icons using a pseudo element
/// @param {String} $class
/// @param {String} $icon-code
/// @param {String} $font-family
/// @content Any other styles
/// @group Typo
/// @author Felix Scholze
/// @since v1.0.0
@mixin icon-font($class, $pseudo, $icon-code, $font-family) {
.icon-#{$class} {
&::#{$pseudo} {
content: #{"'\\"}#{$icon-code + "'"};
font-family: $font-family;
@content;
}
}
}
/// Adds fonts via @font-face
///
/// @param {String} $name Font-Name
/// @param {String} $path Path to font
/// @param {Number} $weight [null] Font-Weight
/// @param {String} $version [null] Font Version
/// @param {String} $unicode-range [''] Unicode Range
/// @param {String} $style [null] Font-Style
/// @param {List} $exts [woff2 woff] Font-Formats to add
/// @param {String} $display [swap] Display
/// @group Typo
/// @author Felix Scholze
/// @since v1.4.0
///
/// @example
/// @include font-face(
/// 'Open Sans',
/// '#{$path-to-fonts}/opensans/Light/OpenSans-Light',
/// 400,
/// 1.0,
/// '',
/// normal,
/// woff2 woff,
/// );
///
@mixin font-face(
$name,
$path,
$weight: null,
$version: null,
$unicode-range: '',
$style: normal,
$exts: woff2 woff,
$display: swap
) {
$src: null;
@if $version {
$version: '?v=' + $version;
}
@each $ext in $exts {
$src: list.append(
$src,
url('#{$path + '.' + $ext + $version}') format(string.quote($ext)),
comma
);
}
@font-face {
font-weight: $weight;
font-style: $style;
font-family: string.quote($name);
src: local($name), $src;
font-display: $display;
@if $unicode-range {
unicode-range: string.unquote($unicode-range);
}
}
}