( variants: FontVariants, ttf?: boolean, )
| 47 | }; |
| 48 | |
| 49 | const getStaticVariantList = ( |
| 50 | variants: FontVariants, |
| 51 | ttf?: boolean, |
| 52 | ): StaticVariant[] => { |
| 53 | const variantList: StaticVariant[] = []; |
| 54 | for (const [weight, styles] of Object.entries(variants)) { |
| 55 | for (const [style, subsets] of Object.entries(styles)) { |
| 56 | for (const [subset, { url }] of Object.entries(subsets)) { |
| 57 | const props = { |
| 58 | kind: 'static' as const, |
| 59 | weight: Number(weight), |
| 60 | style, |
| 61 | subset: subset.replace('[', '').replace(']', ''), |
| 62 | }; |
| 63 | if (isAbsoluteURL(url.woff2)) { |
| 64 | variantList.push({ |
| 65 | ...props, |
| 66 | url: url.woff2, |
| 67 | extension: 'woff2', |
| 68 | }); |
| 69 | } |
| 70 | if (isAbsoluteURL(url.woff)) { |
| 71 | variantList.push({ |
| 72 | ...props, |
| 73 | url: url.woff, |
| 74 | extension: 'woff', |
| 75 | }); |
| 76 | } |
| 77 | // Include TTF if requested |
| 78 | if (ttf) { |
| 79 | if (url.truetype && isAbsoluteURL(url.truetype)) { |
| 80 | variantList.push({ |
| 81 | ...props, |
| 82 | url: url.truetype, |
| 83 | extension: 'ttf', |
| 84 | }); |
| 85 | } |
| 86 | if (url.opentype && isAbsoluteURL(url.opentype)) { |
| 87 | variantList.push({ |
| 88 | ...props, |
| 89 | url: url.opentype, |
| 90 | extension: 'otf', |
| 91 | }); |
| 92 | } |
| 93 | } |
| 94 | } |
| 95 | } |
| 96 | } |
| 97 | return variantList; |
| 98 | }; |
| 99 | |
| 100 | const getVariableVariantList = ( |
| 101 | variants: FontVariantsVariable, |
no test coverage detected