MCPcopy
hub / github.com/vercel/next.js / load

Method load

packages/next/src/compiled/@vercel/og/index.edge.js:20262–20281  ·  view source on GitHub ↗
(fonts)

Source from the content-addressed store, hash-verified

20260 return null;
20261 }
20262 async load(fonts) {
20263 let params = "";
20264 const existingLang = Object.keys(this.rangesByLang);
20265 const langNeedsToLoad = fonts.filter((font) => !existingLang.includes(font));
20266 if (langNeedsToLoad.length === 0) {
20267 return;
20268 }
20269 for (const font of langNeedsToLoad) {
20270 params += `family=${font}&`;
20271 }
20272 params += "display=swap";
20273 const API = `https://fonts.googleapis.com/css2?${params}`;
20274 const fontFace = await (await fetch(API, {
20275 headers: {
20276 // Make sure it returns TTF.
20277 "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36"
20278 }
20279 })).text();
20280 this.addDetectors(fontFace);
20281 }
20282 addDetectors(input) {
20283 const regex = /font-family:\s*'(.+?)';.+?unicode-range:\s*(.+?);/gms;
20284 const matches = input.matchAll(regex);

Callers

nothing calls this directly

Calls 6

includesMethod · 0.80
keysMethod · 0.65
textMethod · 0.65
fetchFunction · 0.50
filterMethod · 0.45
addDetectorsMethod · 0.45

Tested by

no test coverage detected