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

Function getSourceValue

packages/core/src/css/face-rule.ts:18–36  ·  view source on GitHub ↗
(
	face: FontFace,
	source: FontSource,
	resolver?: UrlResolver,
)

Source from the content-addressed store, hash-verified

16
17// Build one `src` entry per source file.
18const getSourceValue = (
19 face: FontFace,
20 source: FontSource,
21 resolver?: UrlResolver,
22): string => {
23 const url = resolver
24 ? resolver({ face, source })
25 : `./files/${source.filename}`;
26
27 let format = 'woff';
28 if (source.format === 'woff2') {
29 // Special format to make it clear to browsers that this is a variable font.
30 format = face.isVariable ? 'woff2-variations' : 'woff2';
31 } else if (source.format === 'ttf') {
32 format = 'truetype';
33 }
34
35 return `url(${url}) format('${format}')`;
36};
37
38const getFaceComment = (family: string, face: FontFace): string => {
39 const axisOrWeight =

Callers 1

renderFontFaceFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected