Skip to content

Commit

Permalink
fix: ability to load fonts by relative URL in browsers (#1934)
Browse files Browse the repository at this point in the history
  • Loading branch information
carlobeltrame authored Jul 11, 2022
1 parent 811ca16 commit 1a89506
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/violet-nails-accept.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@react-pdf/font': patch
---

fix: ability to load fonts by relative URL in browsers
2 changes: 1 addition & 1 deletion packages/font/src/font.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 1a89506

Please sign in to comment.