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

Fix errors in setGState in PartialEvaluator_getTextContent that prevents text-selection from working properly

Currently `setGState` is completely broken, and looking through the history of that code, it seems to me that this may never have worked correctly.
This patch fixes the text-selection in `extgstate.pdf` in the test-suite, which is also added as a `text` test.
This commit is contained in:
Jonas Jenwald 2016-05-31 23:40:19 +02:00
parent 7c7d239995
commit b02d560ae0
2 changed files with 16 additions and 13 deletions

View file

@ -1402,7 +1402,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
case OPS.setFont:
flushTextContentItem();
textState.fontSize = args[1];
next(handleSetFont(args[0].name));
next(handleSetFont(args[0].name, null));
return;
case OPS.setTextRise:
flushTextContentItem();
@ -1608,21 +1608,17 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
var dictName = args[0];
var extGState = resources.get('ExtGState');
if (!isDict(extGState) || !extGState.has(dictName.name)) {
if (!isDict(extGState) || !isName(dictName)) {
break;
}
var gsStateMap = extGState.get(dictName.name);
var gsStateFont = null;
for (var key in gsStateMap) {
if (key === 'Font') {
assert(!gsStateFont);
gsStateFont = gsStateMap[key];
}
var gState = extGState.get(dictName.name);
if (!isDict(gState)) {
break;
}
if (gsStateFont) {
textState.fontSize = gsStateFont[1];
next(handleSetFont(gsStateFont[0]));
var gStateFont = gState.get('Font');
if (gStateFont) {
textState.fontSize = gStateFont[1];
next(handleSetFont(null, gStateFont[0]));
return;
}
break;