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

Function pickVariableIndexCSS

packages/core/src/css/planner.ts:35–53  ·  view source on GitHub ↗
(
	variable: FontConfig['variable'],
	facesByCSSFile: ReadonlyMap<string, readonly FontFace[]>,
)

Source from the content-addressed store, hash-verified

33};
34
35const pickVariableIndexCSS = (
36 variable: FontConfig['variable'],
37 facesByCSSFile: ReadonlyMap<string, readonly FontFace[]>,
38): string | undefined => {
39 if (!variable) {
40 return undefined;
41 }
42
43 // Prefer the primary-axis normal file, but fall back to the italic file.
44 const axisKey = determineAxisKey(variable);
45 const normalKey = `${axisKey}.css`;
46
47 if (facesByCSSFile.has(normalKey)) {
48 return normalKey;
49 }
50
51 const italicKey = `${axisKey}-italic.css`;
52 return facesByCSSFile.has(italicKey) ? italicKey : undefined;
53};
54
55// One resolved face can feed multiple published CSS files, for example a static
56// italic face contributes to both `400-italic.css` and `latin-italic.css`.

Callers 2

generateFaceCSSAssetsFunction · 0.90

Calls 1

determineAxisKeyFunction · 0.90

Tested by

no test coverage detected