( styleValues: StyleValues, )
| 42 | |
| 43 | /** Convert Glypht style values into Fontsource weight/style metadata. */ |
| 44 | const extractFontStyle = ( |
| 45 | styleValues: StyleValues, |
| 46 | ): { weight: number; style: FontStyle } => { |
| 47 | const weight = extractStyleValue(styleValues.weight); |
| 48 | const italicValue = extractStyleValue(styleValues.italic); |
| 49 | const slantValue = extractStyleValue(styleValues.slant); |
| 50 | |
| 51 | if (italicValue > 0) { |
| 52 | return { weight, style: 'italic' }; |
| 53 | } |
| 54 | |
| 55 | if (slantValue !== 0) { |
| 56 | const style = `oblique ${formatSlantValue({ |
| 57 | min: slantValue, |
| 58 | max: slantValue, |
| 59 | })}` as FontStyle; |
| 60 | |
| 61 | return { weight, style }; |
| 62 | } |
| 63 | |
| 64 | return { weight, style: 'normal' }; |
| 65 | }; |
| 66 | |
| 67 | /** |
| 68 | * Build packaged font assets and matching CSS from raw font buffers. |
no test coverage detected