( variable: FontConfig['variable'], facesByCSSFile: ReadonlyMap<string, readonly FontFace[]>, )
| 33 | }; |
| 34 | |
| 35 | const 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`. |
no test coverage detected