MCPcopy Create free account
hub / github.com/fontsource/fontsource / findClosestFace

Function findClosestFace

packages/core/src/css/planner.ts:12–19  ·  view source on GitHub ↗
(candidates: readonly StaticFace[])

Source from the content-addressed store, hash-verified

10// which do not have weight 400, or are only italic.
11const pickStaticIndexCSS = (faces: FontFace[]): string | undefined => {
12 const findClosestFace = (candidates: readonly StaticFace[]) => {
13 if (candidates.length === 0) {
14 return undefined;
15 }
16
17 const weight = findClosestWeight(candidates.map((face) => face.weight));
18 return candidates.find((face) => face.weight === weight);
19 };
20
21 const staticFaces = faces.filter(isStaticFace);
22 const normalFaces = staticFaces.filter((face) => face.style === 'normal');

Callers 1

pickStaticIndexCSSFunction · 0.85

Calls 1

findClosestWeightFunction · 0.90

Tested by

no test coverage detected