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

Function extractFontStyle

packages/core/src/processor.ts:44–65  ·  view source on GitHub ↗
(
	styleValues: StyleValues,
)

Source from the content-addressed store, hash-verified

42
43/** Convert Glypht style values into Fontsource weight/style metadata. */
44const extractFontStyle = (
45 styleValues: StyleValues,
46): { weight: number; style: FontStyle } => {
47 const weight = extractStyleValue(styleValues.weight);
48 const italicValue = extractStyleValue(styleValues.italic);
49 const slantValue = extractStyleValue(styleValues.slant);
50
51 if (italicValue > 0) {
52 return { weight, style: 'italic' };
53 }
54
55 if (slantValue !== 0) {
56 const style = `oblique ${formatSlantValue({
57 min: slantValue,
58 max: slantValue,
59 })}` as FontStyle;
60
61 return { weight, style };
62 }
63
64 return { weight, style: 'normal' };
65};
66
67/**
68 * Build packaged font assets and matching CSS from raw font buffers.

Callers 2

buildFamilySettingsFunction · 0.85
buildFontFunction · 0.85

Calls 2

extractStyleValueFunction · 0.90
formatSlantValueFunction · 0.90

Tested by

no test coverage detected