MCPcopy Index your code
hub / github.com/fontsource/fontsource / getStaticVariantList

Function getStaticVariantList

packages/cli/src/google/download.ts:49–98  ·  view source on GitHub ↗
(
	variants: FontVariants,
	ttf?: boolean,
)

Source from the content-addressed store, hash-verified

47};
48
49const 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
100const getVariableVariantList = (
101 variants: FontVariantsVariable,

Callers 2

download.test.tsFile · 0.90
staticLinksFunction · 0.85

Calls 2

isAbsoluteURLFunction · 0.85
replaceMethod · 0.65

Tested by

no test coverage detected