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

Function deriveBaseName

packages/core/src/conversion.ts:17–38  ·  view source on GitHub ↗
(
	glyphtContext: FontContext['glyphtContext'],
	ttfBuffer: Uint8Array,
)

Source from the content-addressed store, hash-verified

15};
16
17const deriveBaseName = async (
18 glyphtContext: FontContext['glyphtContext'],
19 ttfBuffer: Uint8Array,
20): Promise<string> => {
21 const fontRefs = await glyphtContext.loadFonts([ttfBuffer]);
22
23 try {
24 const [fontRef] = fontRefs;
25
26 if (!fontRef) {
27 return 'font';
28 }
29
30 const family = normalizeKebabCase(fontRef.familyName);
31 const subFamily = normalizeKebabCase(fontRef.subfamilyName);
32 return `${family}-${subFamily}`;
33 } finally {
34 for (const fontRef of fontRefs) {
35 fontRef.destroy();
36 }
37 }
38};
39
40/**
41 * Converts a font buffer into multiple webfont formats (TTF, WOFF, WOFF2).

Callers 1

convertFontFunction · 0.85

Calls 2

normalizeKebabCaseFunction · 0.90
destroyMethod · 0.80

Tested by

no test coverage detected