Ensure that PartialEvaluator_extractWidths is able to handle indirect objects in all kinds of "width" data (issue 7855)

Fixes 7855.
This commit is contained in:
Jonas Jenwald 2016-11-29 18:28:32 +01:00
parent 451956c0b1
commit c5b06cb40d
4 changed files with 24 additions and 8 deletions

View File

@ -1997,14 +1997,14 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
widths = dict.get('W'); widths = dict.get('W');
if (widths) { if (widths) {
for (i = 0, ii = widths.length; i < ii; i++) { for (i = 0, ii = widths.length; i < ii; i++) {
start = widths[i++]; start = xref.fetchIfRef(widths[i++]);
code = xref.fetchIfRef(widths[i]); code = xref.fetchIfRef(widths[i]);
if (isArray(code)) { if (isArray(code)) {
for (j = 0, jj = code.length; j < jj; j++) { for (j = 0, jj = code.length; j < jj; j++) {
glyphsWidths[start++] = code[j]; glyphsWidths[start++] = xref.fetchIfRef(code[j]);
} }
} else { } else {
var width = widths[++i]; var width = xref.fetchIfRef(widths[++i]);
for (j = start; j <= code; j++) { for (j = start; j <= code; j++) {
glyphsWidths[j] = width; glyphsWidths[j] = width;
} }
@ -2013,19 +2013,27 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
} }
if (properties.vertical) { if (properties.vertical) {
var vmetrics = (dict.get('DW2') || [880, -1000]); var vmetrics = dict.getArray('DW2') || [880, -1000];
defaultVMetrics = [vmetrics[1], defaultWidth * 0.5, vmetrics[0]]; defaultVMetrics = [vmetrics[1], defaultWidth * 0.5, vmetrics[0]];
vmetrics = dict.get('W2'); vmetrics = dict.get('W2');
if (vmetrics) { if (vmetrics) {
for (i = 0, ii = vmetrics.length; i < ii; i++) { for (i = 0, ii = vmetrics.length; i < ii; i++) {
start = vmetrics[i++]; start = xref.fetchIfRef(vmetrics[i++]);
code = xref.fetchIfRef(vmetrics[i]); code = xref.fetchIfRef(vmetrics[i]);
if (isArray(code)) { if (isArray(code)) {
for (j = 0, jj = code.length; j < jj; j++) { for (j = 0, jj = code.length; j < jj; j++) {
glyphsVMetrics[start++] = [code[j++], code[j++], code[j]]; glyphsVMetrics[start++] = [
xref.fetchIfRef(code[j++]),
xref.fetchIfRef(code[j++]),
xref.fetchIfRef(code[j])
];
} }
} else { } else {
var vmetric = [vmetrics[++i], vmetrics[++i], vmetrics[++i]]; var vmetric = [
xref.fetchIfRef(vmetrics[++i]),
xref.fetchIfRef(vmetrics[++i]),
xref.fetchIfRef(vmetrics[++i])
];
for (j = start; j <= code; j++) { for (j = start; j <= code; j++) {
glyphsVMetrics[j] = vmetric; glyphsVMetrics[j] = vmetric;
} }
@ -2039,7 +2047,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
if (widths) { if (widths) {
j = firstChar; j = firstChar;
for (i = 0, ii = widths.length; i < ii; i++) { for (i = 0, ii = widths.length; i < ii; i++) {
glyphsWidths[j++] = widths[i]; glyphsWidths[j++] = xref.fetchIfRef(widths[i]);
} }
defaultWidth = (parseFloat(descriptor.get('MissingWidth')) || 0); defaultWidth = (parseFloat(descriptor.get('MissingWidth')) || 0);
} else { } else {

View File

@ -42,6 +42,7 @@
!issue7598.pdf !issue7598.pdf
!issue7665.pdf !issue7665.pdf
!issue7835.pdf !issue7835.pdf
!issue7855.pdf
!bad-PageLabels.pdf !bad-PageLabels.pdf
!filled-background.pdf !filled-background.pdf
!ArabicCIDTrueType.pdf !ArabicCIDTrueType.pdf

BIN
test/pdfs/issue7855.pdf Normal file

Binary file not shown.

View File

@ -1853,6 +1853,13 @@
"rounds": 1, "rounds": 1,
"type": "eq" "type": "eq"
}, },
{ "id": "issue7855",
"file": "pdfs/issue7855.pdf",
"md5": "290d4d5da041ffbcb1ea5d3b0ed8ee91",
"rounds": 1,
"link": false,
"type": "eq"
},
{ "id": "issue6068", { "id": "issue6068",
"file": "pdfs/issue6068.pdf", "file": "pdfs/issue6068.pdf",
"md5": "bbcedb94776b40352729c16940a5b2bd", "md5": "bbcedb94776b40352729c16940a5b2bd",