diff --git a/src/core/fonts.js b/src/core/fonts.js index c03fbb62f..eec37b85d 100644 --- a/src/core/fonts.js +++ b/src/core/fonts.js @@ -1554,6 +1554,8 @@ var Font = (function FontClosure() { function readTrueTypeCollectionData(ttc, fontName) { const { numFonts, offsetTable } = readTrueTypeCollectionHeader(ttc); + const fontNameParts = fontName.split("+"); + let fallbackData; for (let i = 0; i < numFonts; i++) { ttc.pos = (ttc.start || 0) + offsetTable[i]; @@ -1569,16 +1571,42 @@ var Font = (function FontClosure() { for (let j = 0, jj = nameTable.length; j < jj; j++) { for (let k = 0, kk = nameTable[j].length; k < kk; k++) { - const nameEntry = nameTable[j][k]; - if (nameEntry && nameEntry.replace(/\s/g, "") === fontName) { + const nameEntry = + nameTable[j][k] && nameTable[j][k].replace(/\s/g, ""); + if (!nameEntry) { + continue; + } + if (nameEntry === fontName) { return { header: potentialHeader, tables: potentialTables, }; } + if (fontNameParts.length < 2) { + continue; + } + for (const part of fontNameParts) { + if (nameEntry === part) { + fallbackData = { + name: part, + header: potentialHeader, + tables: potentialTables, + }; + } + } } } } + if (fallbackData) { + warn( + `TrueType Collection does not contain "${fontName}" font, ` + + `falling back to "${fallbackData.name}" font instead.` + ); + return { + header: fallbackData.header, + tables: fallbackData.tables, + }; + } throw new FormatError( `TrueType Collection does not contain "${fontName}" font.` ); diff --git a/test/pdfs/.gitignore b/test/pdfs/.gitignore index 15f105b38..f30f9f80e 100644 --- a/test/pdfs/.gitignore +++ b/test/pdfs/.gitignore @@ -385,6 +385,7 @@ !issue9278.pdf !annotation-text-without-popup.pdf !annotation-underline.pdf +!issue13193.pdf !annotation-underline-without-appearance.pdf !issue269_2.pdf !annotation-strikeout.pdf diff --git a/test/pdfs/issue13193.pdf b/test/pdfs/issue13193.pdf new file mode 100644 index 000000000..5f5cf9ae5 Binary files /dev/null and b/test/pdfs/issue13193.pdf differ diff --git a/test/test_manifest.json b/test/test_manifest.json index 319959420..7cd0787d5 100644 --- a/test/test_manifest.json +++ b/test/test_manifest.json @@ -3095,6 +3095,12 @@ "link": true, "type": "eq" }, + { "id": "issue13193", + "file": "pdfs/issue13193.pdf", + "md5": "38cf058f58b7dc5dc54e1602580936a7", + "rounds": 1, + "type": "eq" + }, { "id": "issue1655", "file": "pdfs/issue1655r.pdf", "md5": "569f48449ba57c15c4f9ade151a651c5",