From af8292058fe0fc4b89d83116772ce89380dfc7e8 Mon Sep 17 00:00:00 2001 From: pmysore1 Date: Sat, 11 Feb 2017 01:25:05 -0500 Subject: [PATCH] Font ascent descent calculation fix --- src/core/cff_parser.js | 4 ++-- src/core/type1_parser.js | 4 ++-- test/pdfs/.gitignore | 1 + test/pdfs/font_ascent_descent.pdf | Bin 0 -> 15056 bytes test/test_manifest.json | 6 ++++++ 5 files changed, 11 insertions(+), 4 deletions(-) create mode 100755 test/pdfs/font_ascent_descent.pdf diff --git a/src/core/cff_parser.js b/src/core/cff_parser.js index 22c109257..24f7ca648 100644 --- a/src/core/cff_parser.js +++ b/src/core/cff_parser.js @@ -257,8 +257,8 @@ var CFFParser = (function CFFParserClosure() { var fontBBox = topDict.getByName('FontBBox'); if (fontBBox) { // adjusting ascent/descent - properties.ascent = fontBBox[3]; - properties.descent = fontBBox[1]; + properties.ascent = Math.max(fontBBox[3], fontBBox[1]); + properties.descent = Math.min(fontBBox[1], fontBBox[3]); properties.ascentScaled = true; } diff --git a/src/core/type1_parser.js b/src/core/type1_parser.js index 48b206fe7..323d3b253 100644 --- a/src/core/type1_parser.js +++ b/src/core/type1_parser.js @@ -705,8 +705,8 @@ var Type1Parser = (function Type1ParserClosure() { case 'FontBBox': var fontBBox = this.readNumberArray(); // adjusting ascent/descent - properties.ascent = fontBBox[3]; - properties.descent = fontBBox[1]; + properties.ascent = Math.max(fontBBox[3], fontBBox[1]); + properties.descent = Math.min(fontBBox[1], fontBBox[3]); properties.ascentScaled = true; break; } diff --git a/test/pdfs/.gitignore b/test/pdfs/.gitignore index 236db80c9..3353c9679 100644 --- a/test/pdfs/.gitignore +++ b/test/pdfs/.gitignore @@ -271,3 +271,4 @@ !zero_descent.pdf !operator-in-TJ-array.pdf !issue7878.pdf +!font_ascent_descent.pdf diff --git a/test/pdfs/font_ascent_descent.pdf b/test/pdfs/font_ascent_descent.pdf new file mode 100755 index 0000000000000000000000000000000000000000..85872bcbbdc6c54795390bb124d2621238007df7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test/test_manifest.json +++ b/test/test_manifest.json @@ -3367,5 +3367,11 @@ "link": false, "rounds": 1, "type": "text" + }, + { "id": "font_ascent_descent", + "file": "pdfs/font_ascent_descent.pdf", + "md5": "c0048a7735010002b998c112335e47bf", + "rounds": 1, + "type": "eq" } ]