Skip to content

Commit

Permalink
Fixed refetching fonts from URL #2477
Browse files Browse the repository at this point in the history
  • Loading branch information
liborm85 committed Sep 17, 2022
1 parent c02a4de commit c6e37a1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- Updated Roboto font (version 3.005)
- Fixed calculating auto page height
- Fixed TrueType Collection loading from URL
- Fixed refetching fonts from URL

## 0.3.0-beta.2 - 2022-04-01

Expand Down
15 changes: 10 additions & 5 deletions src/URLResolver.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,17 @@ class URLResolver {
if (!this.resolving[url]) {
this.resolving[url] = new Promise((resolve, reject) => {
if (url.toLowerCase().indexOf('https://') === 0 || url.toLowerCase().indexOf('http://') === 0) {
fetchUrl(url, headers).then(buffer => {
this.fs.writeFileSync(url, buffer);
if (this.fs.existsSync(url)) {
// url was downloaded earlier
resolve();
}, result => {
reject(result);
});
} else {
fetchUrl(url, headers).then(buffer => {
this.fs.writeFileSync(url, buffer);
resolve();
}, result => {
reject(result);
});
}
} else {
// cannot be resolved
resolve();
Expand Down

0 comments on commit c6e37a1

Please sign in to comment.