(family: string)
| 30 | * @async |
| 31 | */ |
| 32 | export async function getMetricsForFamily(family: string): Promise<FontFaceMetrics | null> { |
| 33 | family = withoutQuotes(family) |
| 34 | |
| 35 | if (family in metricCache) |
| 36 | return metricCache[family] ?? null |
| 37 | |
| 38 | try { |
| 39 | const name = fontFamilyToCamelCase(family) |
| 40 | const { entireMetricsCollection } = await import('#capsize-font-metrics') as any as typeof import('@capsizecss/metrics/entireMetricsCollection') |
| 41 | const metrics = entireMetricsCollection[name as keyof typeof entireMetricsCollection] |
| 42 | |
| 43 | /* v8 ignore next 4 */ |
| 44 | if (!('descent' in metrics)) { |
| 45 | metricCache[family] = null |
| 46 | return null |
| 47 | } |
| 48 | |
| 49 | const filteredMetrics = filterRequiredMetrics(metrics) |
| 50 | metricCache[family] = filteredMetrics |
| 51 | return filteredMetrics |
| 52 | } |
| 53 | catch { |
| 54 | metricCache[family] = null |
| 55 | return null |
| 56 | } |
| 57 | } |
| 58 | |
| 59 | const urlRequestCache = new Map<string, Promise<Font>>() |
| 60 |
no test coverage detected