|
|
@@ -81,7 +81,11 @@ this.docHelper = this.docHelper || (() => {
|
|
|
elementsInfo = new Map(Array.from(elementsInfo).filter(([element]) => element.getAttribute(markerRemovedContent) != ""));
|
|
|
}
|
|
|
if (options.removeUnusedStyles) {
|
|
|
- usedFonts = getUsedFonts(elementsInfo, Array.from(doc.fonts).filter(font => font.status == "loaded" || font.status == "loading"));
|
|
|
+ let loadedFonts;
|
|
|
+ if (doc.fonts) {
|
|
|
+ loadedFonts = Array.from(doc.fonts).filter(font => font.status == "loaded" || font.status == "loading");
|
|
|
+ }
|
|
|
+ usedFonts = getUsedFonts(elementsInfo, loadedFonts);
|
|
|
}
|
|
|
if (options.compressHTML) {
|
|
|
elementsInfo.forEach((elementInfo, element) => {
|
|
|
@@ -122,7 +126,7 @@ this.docHelper = this.docHelper || (() => {
|
|
|
const fontFamilyNames = style.fontFamily.split(",");
|
|
|
fontFamilyNames.forEach(fontFamilyName => {
|
|
|
fontFamilyName = removeQuotes(fontFamilyName.trim()).toLowerCase();
|
|
|
- if (loadedFonts.find(font => font.family.toLowerCase() == fontFamilyName && font.style == style.fontStyle && font.weight == style.fontWeight && font.weight == style.fontWeight && font.variant == style.fontVariant)) {
|
|
|
+ if (!loadedFonts || loadedFonts.find(font => font.family.toLowerCase() == fontFamilyName && font.style == style.fontStyle && font.weight == style.fontWeight && font.weight == style.fontWeight && font.variant == style.fontVariant)) {
|
|
|
const { fontWeight, fontStyle, fontVariant } = style;
|
|
|
usedFonts.add([fontFamilyName, fontWeight, fontStyle, fontVariant]);
|
|
|
}
|