source: imaps-frontend/node_modules/@fontsource/roboto/scss/mixins.scss

main
Last change on this file was 0c6b92a, checked in by stefan toskovski <stefantoska84@…>, 5 weeks ago

Pred finalna verzija

  • Property mode set to 100644
File size: 5.7 KB
Line 
1@use 'sass:list';
2@use 'sass:map';
3@use 'sass:math';
4@use 'sass:meta';
5@use 'sass:string';
6
7@use 'metadata';
8
9$metadata: meta.module-variables(metadata) !default;
10$directory: null !default;
11
12$family: null !default;
13$display: null !default;
14$formats: null !default;
15$subsets: null !default;
16$weights: null !default;
17$styles: null !default;
18$axes: null !default;
19
20// Deprecated
21$displayVar: null !default;
22
23@mixin generator(
24 $metadata: $metadata,
25 $directory: $directory,
26 $family: $family,
27 $display: $display,
28 $formats: $formats,
29 $subsets: $subsets,
30 $weights: $weights,
31 $styles: $styles,
32 $axes: $axes,
33
34 // Deprecated
35 $displayVar: $displayVar
36) {
37
38 @if $displayVar != null {
39 @warn "$displayVar is deprecated due to the limitation of using css variables in @font-face (https://github.com/fontsource/fontsource/issues/726).";
40 }
41
42 $isVariable: map.get($metadata, axes) != null;
43
44 $directory: if(
45 $directory,
46 $directory,
47 '~@fontsource#{if($isVariable, '-variable', '')}/#{map.get($metadata, id)}/files'
48 );
49
50 $family: if($family, $family, map.get($metadata, family) + if($isVariable, ' Variable', ''));
51 $display: if($display, $display, swap);
52 $formats: if(not $formats or $formats == all, if($isVariable, woff2, (woff2, woff)), $formats);
53 $subsets: if(
54 $subsets,
55 if($subsets == all, map.get($metadata, subsets), $subsets),
56 map.get($metadata, subsets)
57 );
58 $weights: if(
59 $weights,
60 if($weights == all, map.get($metadata, weights), $weights),
61 map.get($metadata, defaults, weight)
62 );
63 $styles: if(
64 $styles,
65 if($styles == all, map.get($metadata, styles), $styles),
66 map.get($metadata, defaults, style)
67 );
68 $axes: if(
69 $axes,
70 if($axes == all, full, $axes),
71 if($isVariable, if(map.has-key($metadata, axes, wght), wght, full), null)
72 );
73
74 @each $subset in $subsets {
75 @each $unicodeSubset, $unicodeRange in map.get($metadata, unicode) {
76 // If condition is true, generate faces for the current subset
77 @if (
78 // If there is no unicode information for the font or
79 ($unicodeSubset == null) or
80 // If the subset match a unicode subset or
81 ($subset == $unicodeSubset) or
82 (
83 // If $unicodeSubset is a numeric unicode subset
84 // and current subset exists in the list of font subsets but does not match any unicode subset
85 // then generate faces for this numeric unicode subset as it is representing part of the current subset
86 list.index(map.get($metadata, subsets), $subset) and not
87 map.has-key($metadata, unicode, $subset) and not
88 list.index(map.get($metadata, subsets), $unicodeSubset)
89 )
90 ) {
91 @each $weight in if($axes, null, $weights) {
92 @each $axis in $axes {
93 @each $style in $styles {
94 $variant: '#{map.get($metadata, id)}-#{if($unicodeSubset, $unicodeSubset, $subset)}-#{if($axis, $axis, $weight)}-#{$style}';
95
96 $src: ();
97 @each $format in $formats {
98 $src: append(
99 $src,
100 url('#{$directory}/#{$variant}.#{$format}')
101 format('#{$format}#{if($axis, '-variations', '')}'),
102 comma
103 );
104 }
105
106 @content ((
107 metadata: $metadata,
108 directory: $directory,
109 family: $family,
110 display: $display,
111 formats: $formats,
112 subsets: $subsets,
113 weights: $weights,
114 styles: $styles,
115 axes: $axes,
116
117 variant: $variant,
118 subset: $subset,
119 unicodeSubset: $unicodeSubset,
120 unicodeRange: $unicodeRange,
121 weight: $weight,
122 axis: $axis,
123 style: $style,
124
125 font-family: string.quote($family),
126 font-style: if(
127 (($axis == full) or ($axis == slnt)) and map.has-key($metadata, axes, slnt),
128 oblique map.get($metadata, axes, slnt, min) + deg map.get($metadata, axes, slnt, max) + deg,
129 $style
130 ),
131 font-display: $display,
132 font-weight: if(
133 (($axis == full) or ($axis == wght)) and map.has-key($metadata, axes, wght),
134 map.get($metadata, axes, wght, min) map.get($metadata, axes, wght, max),
135 $weight
136 ),
137 font-stretch: if(
138 (($axis == full) or ($axis == wdth)) and map.has-key($metadata, axes, wdth),
139 '#{map.get($metadata, axes, wdth, min)}% #{map.get($metadata, axes, wdth, max)}%',
140 null
141 ),
142 src: $src,
143 unicode-range: $unicodeRange,
144 ));
145 }
146 }
147 }
148 }
149 }
150 }
151}
152
153@mixin faces(
154 $metadata: $metadata,
155 $directory: $directory,
156 $family: $family,
157 $display: $display,
158 $formats: $formats,
159 $subsets: $subsets,
160 $weights: $weights,
161 $styles: $styles,
162 $axes: $axes,
163
164 // Deprecated
165 $displayVar: $displayVar
166) {
167 @include generator(
168 $metadata: $metadata,
169 $directory: $directory,
170 $family: $family,
171 $display: $display,
172 $formats: $formats,
173 $subsets: $subsets,
174 $weights: $weights,
175 $styles: $styles,
176 $axes: $axes,
177
178 $displayVar: $displayVar
179 )
180 using ($props) {
181 /* #{map.get($props, variant)} */
182 @font-face {
183 font-family: map.get($props, font-family);
184 font-style: map.get($props, font-style);
185 font-display: map.get($props, font-display);
186 font-weight: map.get($props, font-weight);
187 font-stretch: map.get($props, font-stretch);
188 unicode-range: map.get($props, unicode-range);
189 src: map.get($props, src);
190 }
191 }
192}
Note: See TracBrowser for help on using the repository browser.