Merge pull request #10628 from Snuffleupagus/bug-1513120

Try to improve text-selection for Type3 fonts that utilize a non-default /FontMatrix (bug 1513120)
This commit is contained in:
Tim van der Meij 2019-03-13 00:05:41 +01:00 committed by GitHub
commit 0abd0bc5ff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 31 additions and 8 deletions

View File

@ -15,8 +15,8 @@
import { import {
AbortException, assert, CMapCompressionType, createPromiseCapability, AbortException, assert, CMapCompressionType, createPromiseCapability,
FONT_IDENTITY_MATRIX, FormatError, IDENTITY_MATRIX, info, isNum, isString, FONT_IDENTITY_MATRIX, FormatError, IDENTITY_MATRIX, info, isArrayEqual, isNum,
NativeImageDecoding, OPS, stringToPDFString, TextRenderingMode, isString, NativeImageDecoding, OPS, stringToPDFString, TextRenderingMode,
UNSUPPORTED_FEATURES, Util, warn UNSUPPORTED_FEATURES, Util, warn
} from '../shared/util'; } from '../shared/util';
import { CMapFactory, IdentityCMap } from './cmap'; import { CMapFactory, IdentityCMap } from './cmap';
@ -1264,13 +1264,11 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
0, textState.fontSize, 0, textState.fontSize,
0, textState.textRise]; 0, textState.textRise];
if (font.isType3Font && if (font.isType3Font && textState.fontSize <= 1 &&
textState.fontMatrix !== FONT_IDENTITY_MATRIX && !isArrayEqual(textState.fontMatrix, FONT_IDENTITY_MATRIX)) {
textState.fontSize === 1) { const glyphHeight = font.bbox[3] - font.bbox[1];
var glyphHeight = font.bbox[3] - font.bbox[1];
if (glyphHeight > 0) { if (glyphHeight > 0) {
glyphHeight = glyphHeight * textState.fontMatrix[3]; tsm[3] *= (glyphHeight * textState.fontMatrix[3]);
tsm[3] *= glyphHeight;
} }
} }

View File

@ -824,6 +824,15 @@ function isArrayBuffer(v) {
return typeof v === 'object' && v !== null && v.byteLength !== undefined; 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. // Checks if ch is one of the following characters: SPACE, TAB, CR or LF.
function isSpace(ch) { function isSpace(ch) {
return (ch === 0x20 || ch === 0x09 || ch === 0x0D || ch === 0x0A); return (ch === 0x20 || ch === 0x09 || ch === 0x0D || ch === 0x0A);
@ -927,6 +936,7 @@ export {
getVerbosityLevel, getVerbosityLevel,
info, info,
isArrayBuffer, isArrayBuffer,
isArrayEqual,
isBool, isBool,
isEmptyObj, isEmptyObj,
isNum, isNum,

View File

@ -93,6 +93,7 @@
!bug1146106.pdf !bug1146106.pdf
!bug1245391_reduced.pdf !bug1245391_reduced.pdf
!bug1252420.pdf !bug1252420.pdf
!bug1513120_reduced.pdf
!issue9949.pdf !issue9949.pdf
!bug1308536.pdf !bug1308536.pdf
!bug1337429.pdf !bug1337429.pdf

Binary file not shown.

View File

@ -1016,6 +1016,20 @@
"link": false, "link": false,
"type": "eq" "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", { "id": "bug1250079",
"file": "pdfs/bug1250079.pdf", "file": "pdfs/bug1250079.pdf",
"md5": "a1dd21a70ae7097d96273e85a80b26ef", "md5": "a1dd21a70ae7097d96273e85a80b26ef",