diff --git a/src/core/evaluator.js b/src/core/evaluator.js index c512c952e..dd13aeb64 100644 --- a/src/core/evaluator.js +++ b/src/core/evaluator.js @@ -15,8 +15,8 @@ import { AbortException, assert, CMapCompressionType, createPromiseCapability, - FONT_IDENTITY_MATRIX, FormatError, IDENTITY_MATRIX, info, isNum, isString, - NativeImageDecoding, OPS, stringToPDFString, TextRenderingMode, + FONT_IDENTITY_MATRIX, FormatError, IDENTITY_MATRIX, info, isArrayEqual, isNum, + isString, NativeImageDecoding, OPS, stringToPDFString, TextRenderingMode, UNSUPPORTED_FEATURES, Util, warn } from '../shared/util'; import { CMapFactory, IdentityCMap } from './cmap'; @@ -1264,13 +1264,11 @@ var PartialEvaluator = (function PartialEvaluatorClosure() { 0, textState.fontSize, 0, textState.textRise]; - if (font.isType3Font && - textState.fontMatrix !== FONT_IDENTITY_MATRIX && - textState.fontSize === 1) { - var glyphHeight = font.bbox[3] - font.bbox[1]; + if (font.isType3Font && textState.fontSize <= 1 && + !isArrayEqual(textState.fontMatrix, FONT_IDENTITY_MATRIX)) { + const glyphHeight = font.bbox[3] - font.bbox[1]; if (glyphHeight > 0) { - glyphHeight = glyphHeight * textState.fontMatrix[3]; - tsm[3] *= glyphHeight; + tsm[3] *= (glyphHeight * textState.fontMatrix[3]); } } diff --git a/src/shared/util.js b/src/shared/util.js index 8a9902b82..35685921f 100644 --- a/src/shared/util.js +++ b/src/shared/util.js @@ -824,6 +824,15 @@ function isArrayBuffer(v) { return typeof v === 'object' && v !== null && v.byteLength !== undefined; } +function isArrayEqual(arr1, arr2) { + if (arr1.length !== arr2.length) { + return false; + } + return arr1.every(function(element, index) { + return element === arr2[index]; + }); +} + // Checks if ch is one of the following characters: SPACE, TAB, CR or LF. function isSpace(ch) { return (ch === 0x20 || ch === 0x09 || ch === 0x0D || ch === 0x0A); @@ -927,6 +936,7 @@ export { getVerbosityLevel, info, isArrayBuffer, + isArrayEqual, isBool, isEmptyObj, isNum, diff --git a/test/pdfs/.gitignore b/test/pdfs/.gitignore index 2d21b3fff..259a95710 100644 --- a/test/pdfs/.gitignore +++ b/test/pdfs/.gitignore @@ -93,6 +93,7 @@ !bug1146106.pdf !bug1245391_reduced.pdf !bug1252420.pdf +!bug1513120_reduced.pdf !issue9949.pdf !bug1308536.pdf !bug1337429.pdf diff --git a/test/pdfs/bug1513120_reduced.pdf b/test/pdfs/bug1513120_reduced.pdf new file mode 100644 index 000000000..f41ef4af9 Binary files /dev/null and b/test/pdfs/bug1513120_reduced.pdf differ diff --git a/test/test_manifest.json b/test/test_manifest.json index b5d8649f0..c188d388e 100644 --- a/test/test_manifest.json +++ b/test/test_manifest.json @@ -1016,6 +1016,20 @@ "link": false, "type": "eq" }, + { "id": "bug1245391-text", + "file": "pdfs/bug1245391_reduced.pdf", + "md5": "6c946045ee0f2f663f269717c0f1614a", + "rounds": 1, + "link": false, + "type": "text" + }, + { "id": "bug1513120-text", + "file": "pdfs/bug1513120_reduced.pdf", + "md5": "e88ad8b5bb385296f475ca51ce0d216d", + "rounds": 1, + "link": false, + "type": "text" + }, { "id": "bug1250079", "file": "pdfs/bug1250079.pdf", "md5": "a1dd21a70ae7097d96273e85a80b26ef",