diff --git a/.changeset/violet-nails-accept.md b/.changeset/violet-nails-accept.md new file mode 100644 index 000000000..26e397155 --- /dev/null +++ b/.changeset/violet-nails-accept.md @@ -0,0 +1,5 @@ +--- +'@react-pdf/font': patch +--- + +fix: ability to load fonts by relative URL in browsers diff --git a/packages/font/src/font.js b/packages/font/src/font.js index bcd3260b0..44595010b 100644 --- a/packages/font/src/font.js +++ b/packages/font/src/font.js @@ -61,7 +61,7 @@ class FontSource { if (isDataUrl(this.src)) { const raw = this.src.split(',')[1]; this.data = fontkit.create(toUint8Array(raw), postscriptName); - } else if (isUrl(this.src)) { + } else if (BROWSER || isUrl(this.src)) { const { headers, body, method = 'GET' } = this.options; const data = await fetchFont(this.src, { method, body, headers }); this.data = fontkit.create(data, postscriptName);