1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-22 16:18:08 +02:00

Merge pull request #7387 from Snuffleupagus/issue-5808

Attempt to ignore multiple identical Tf (setFont) commands in `PartialEvaluator_getTextContent` (issue 5808)
This commit is contained in:
Yury Delendik 2016-08-30 15:21:41 -05:00 committed by GitHub
commit ffa99397ad
4 changed files with 169 additions and 2 deletions

View file

@ -1422,9 +1422,17 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
switch (fn | 0) {
case OPS.setFont:
// Optimization to ignore multiple identical Tf commands.
var fontNameArg = args[0].name, fontSizeArg = args[1];
if (textState.font && fontNameArg === textState.fontName &&
fontSizeArg === textState.fontSize) {
break;
}
flushTextContentItem();
textState.fontSize = args[1];
next(handleSetFont(args[0].name, null));
textState.fontName = fontNameArg;
textState.fontSize = fontSizeArg;
next(handleSetFont(fontNameArg, null));
return;
case OPS.setTextRise:
flushTextContentItem();
@ -1641,6 +1649,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
}
var gStateFont = gState.get('Font');
if (gStateFont) {
textState.fontName = null;
textState.fontSize = gStateFont[1];
next(handleSetFont(null, gStateFont[0]));
return;
@ -2560,6 +2569,7 @@ var StateManager = (function StateManagerClosure() {
var TextState = (function TextStateClosure() {
function TextState() {
this.ctm = new Float32Array(IDENTITY_MATRIX);
this.fontName = null;
this.fontSize = 0;
this.font = null;
this.fontMatrix = FONT_IDENTITY_MATRIX;