From 689caf15410e7fdb8062768acc2eb58495a87dda Mon Sep 17 00:00:00 2001 From: Slobodan Todorov Date: Tue, 24 Jan 2017 16:41:03 +0100 Subject: [PATCH] Extended the fix for issue #42 and added additional hybrid dual bolditalic font detection --- lib/pdffont.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/pdffont.js b/lib/pdffont.js index 99591048..f54e9b27 100644 --- a/lib/pdffont.js +++ b/lib/pdffont.js @@ -215,6 +215,15 @@ let PDFFont = (function PFPFontClosure() { this.bold = this.typeName.indexOf("bold") >= 0 || this.typeName.indexOf("black") >= 0; } this.italic = fontObj.italic; // fix https://github.com/modesty/pdf2json/issues/42 + // Extended the fix for https://github.com/modesty/pdf2json/issues/42 + if (!this.italic) { + this.italic = this.typeName.indexOf("italic") >= 0 || this.typeName.indexOf("oblique") >= 0; + } + // Added detection of hybrid dual bolditalic fonts + if (((!this.bold) || (!this.italic)) && (this.typeName.indexOf("boldobl") >= 0)) { + this.bold = true; + this.italic = true; + } let typeName = this.subType; if (fontObj.isSerifFont) { @@ -382,4 +391,3 @@ let PDFFont = (function PFPFontClosure() { })(); module.exports = PDFFont; -