1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-25 17:48:07 +02:00

Try to improve text-selection for Type3 fonts that utilize a non-default /FontMatrix (bug 1513120)

For Type3 fonts text-selection is often not that great, and there's a couple of heuristics used to try and improve things. This patch simple extends those heuristics a bit, and fixes a pre-existing "naive" array comparison, but this all feels a bit brittle to say the least.

The existing Type3 test-coverage isn't that great in general, and in particular Type3 `text` tests are few and far between, hence why this patch adds *two* different new `text` tests.
This commit is contained in:
Jonas Jenwald 2019-03-08 12:55:44 +01:00
parent d587abbceb
commit 88f9e633dd
5 changed files with 31 additions and 8 deletions

View file

@ -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]);
}
}