MCPcopy
hub / github.com/diegomura/react-pdf / load

Method load

packages/font/src/font.js:60–83  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

58 }
59
60 async load() {
61 this.loading = true;
62
63 const { postscriptName } = this.options;
64
65 if (isDataUrl(this.src)) {
66 this.data = fontkit.create(
67 Buffer.from(this.src.split(',')[1], 'base64'),
68 postscriptName,
69 );
70 } else if (BROWSER || isUrl(this.src)) {
71 const { headers, body, method = 'GET' } = this.options;
72 const data = await fetchFont(this.src, { method, body, headers });
73 this.data = fontkit.create(data, postscriptName);
74 } else {
75 this.data = await new Promise((resolve, reject) =>
76 fontkit.open(this.src, postscriptName, (err, data) =>
77 err ? reject(err) : resolve(data),
78 ),
79 );
80 }
81
82 this.loading = false;
83 }
84}
85
86class Font {

Callers 1

FontStoreFunction · 0.45

Calls 5

isDataUrlFunction · 0.85
fetchFontFunction · 0.85
resolveFunction · 0.85
createMethod · 0.80
openMethod · 0.45

Tested by

no test coverage detected