( variableConfig: VariableAxisConfig, )
| 50 | * Return every published axis key from a variable font config. |
| 51 | */ |
| 52 | export const getVariableAxisKeys = ( |
| 53 | variableConfig: VariableAxisConfig, |
| 54 | ): VariableAxisKey[] => { |
| 55 | // Filter out any inactive axes and `ital` since it's always included. |
| 56 | const direct = Object.keys(variableConfig).filter( |
| 57 | (axisKey) => axisKey !== 'ital' && Boolean(variableConfig[axisKey]), |
| 58 | ); |
| 59 | |
| 60 | const axisKeys = new Set(direct); |
| 61 | const standardAxes = direct.filter((key) => STANDARD_PUBLISHED_AXES.has(key)); |
| 62 | const customAxes = direct.filter((key) => !STANDARD_PUBLISHED_AXES.has(key)); |
| 63 | |
| 64 | if (standardAxes.length > 1) { |
| 65 | axisKeys.add('standard'); |
| 66 | } |
| 67 | |
| 68 | if (customAxes.length > 0) { |
| 69 | axisKeys.add('full'); |
| 70 | } |
| 71 | |
| 72 | return Array.from(axisKeys); |
| 73 | }; |
| 74 | |
| 75 | /** Return the published CSS `font-style` for one axis key variant. */ |
| 76 | export const getFaceStyle = ( |
no outgoing calls
no test coverage detected