Skip to content

Commit

Permalink
fixed TrueType Collection loading from URL #2456
Browse files Browse the repository at this point in the history
  • Loading branch information
liborm85 committed Sep 17, 2022
1 parent 1706602 commit c02a4de
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 12 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

- Updated Roboto font (version 3.005)
- Fixed calculating auto page height
- Fixed TrueType Collection loading from URL

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

Expand Down
48 changes: 36 additions & 12 deletions src/Printer.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,24 +126,48 @@ class PdfPrinter {
for (let font in this.fontDescriptors) {
if (this.fontDescriptors.hasOwnProperty(font)) {
if (this.fontDescriptors[font].normal) {
let url = getExtendedUrl(this.fontDescriptors[font].normal);
this.urlResolver.resolve(url.url, url.headers);
this.fontDescriptors[font].normal = url.url;
if (Array.isArray(this.fontDescriptors[font].normal)) { // TrueType Collection
let url = getExtendedUrl(this.fontDescriptors[font].normal[0]);
this.urlResolver.resolve(url.url, url.headers);
this.fontDescriptors[font].normal[0] = url.url;
} else {
let url = getExtendedUrl(this.fontDescriptors[font].normal);
this.urlResolver.resolve(url.url, url.headers);
this.fontDescriptors[font].normal = url.url;
}
}
if (this.fontDescriptors[font].bold) {
let url = getExtendedUrl(this.fontDescriptors[font].bold);
this.urlResolver.resolve(url.url, url.headers);
this.fontDescriptors[font].bold = url.url;
if (Array.isArray(this.fontDescriptors[font].bold)) { // TrueType Collection
let url = getExtendedUrl(this.fontDescriptors[font].bold[0]);
this.urlResolver.resolve(url.url, url.headers);
this.fontDescriptors[font].bold[0] = url.url;
} else {
let url = getExtendedUrl(this.fontDescriptors[font].bold);
this.urlResolver.resolve(url.url, url.headers);
this.fontDescriptors[font].bold = url.url;
}
}
if (this.fontDescriptors[font].italics) {
let url = getExtendedUrl(this.fontDescriptors[font].italics);
this.urlResolver.resolve(url.url, url.headers);
this.fontDescriptors[font].italics = url.url;
if (Array.isArray(this.fontDescriptors[font].italics)) { // TrueType Collection
let url = getExtendedUrl(this.fontDescriptors[font].italics[0]);
this.urlResolver.resolve(url.url, url.headers);
this.fontDescriptors[font].italics[0] = url.url;
} else {
let url = getExtendedUrl(this.fontDescriptors[font].italics);
this.urlResolver.resolve(url.url, url.headers);
this.fontDescriptors[font].italics = url.url;
}
}
if (this.fontDescriptors[font].bolditalics) {
let url = getExtendedUrl(this.fontDescriptors[font].bolditalics);
this.urlResolver.resolve(url.url, url.headers);
this.fontDescriptors[font].bolditalics = url.url;
if (Array.isArray(this.fontDescriptors[font].bolditalics)) { // TrueType Collection
let url = getExtendedUrl(this.fontDescriptors[font].bolditalics[0]);
this.urlResolver.resolve(url.url, url.headers);
this.fontDescriptors[font].bolditalics[0] = url.url;
} else {
let url = getExtendedUrl(this.fontDescriptors[font].bolditalics);
this.urlResolver.resolve(url.url, url.headers);
this.fontDescriptors[font].bolditalics = url.url;
}
}
}
}
Expand Down

0 comments on commit c02a4de

Please sign in to comment.