MCPcopy Create free account
hub / github.com/wavetermdev/waveterm / getTtfFont

Function getTtfFont

docs/src/renderer/image-renderers.ts:116–130  ·  view source on GitHub ↗
(family: string, axes: string[], value: number[])

Source from the content-addressed store, hash-verified

114}
115
116async function getTtfFont(family: string, axes: string[], value: number[]): Promise<ArrayBuffer> {
117 const familyParam = axes.join(",") + "@" + value.join(",");
118
119 // Get css style sheet with user agent Mozilla/5.0 Firefox/1.0 to ensure TTF is returned
120 const cssCall = await fetch(`https://fonts.googleapis.com/css2?family=${family}:${familyParam}&display=swap`, {
121 headers: {
122 "User-Agent": "Mozilla/5.0 Firefox/1.0",
123 },
124 });
125
126 const css = await cssCall.text();
127 const ttfUrl = css.match(/url\(([^)]+)\)/)?.[1];
128
129 return await fetch(ttfUrl).then((res) => res.arrayBuffer());
130}

Callers 1

imageGeneratorOptionsFunction · 0.85

Calls 1

fetchFunction · 0.85

Tested by

no test coverage detected