LibPDF: Swap int and array branches in outline item reading

No intended behavior change.

It does have the effect that indirect object references now go down
the array path instead of the number path. They still fall over there,
but now that's easy to fix.
This commit is contained in:
Nico Weber 2023-10-24 20:44:25 -07:00 committed by Andreas Kling
parent 208a058eab
commit b928fadba7
Notes: sideshowbarker 2024-07-19 01:59:31 +09:00

View file

@ -134,12 +134,7 @@ PDFErrorOr<void> Type0Font::initialize(Document* document, NonnullRefPtr<DictObj
auto& value = widths_array->at(i);
if (!pending_code.has_value()) {
pending_code = value.to_int();
} else if (value.has<NonnullRefPtr<Object>>()) {
auto array = value.get<NonnullRefPtr<Object>>()->cast<ArrayObject>();
auto code = pending_code.release_value();
for (auto& width : *array)
widths.set(code++, width.to_int());
} else {
} else if (value.has_number()) {
auto first_code = pending_code.release_value();
auto last_code = value.to_int();
auto width = widths_array->at(i + 1).to_int();
@ -147,6 +142,11 @@ PDFErrorOr<void> Type0Font::initialize(Document* document, NonnullRefPtr<DictObj
widths.set(code, width);
i++;
} else {
auto array = value.get<NonnullRefPtr<Object>>()->cast<ArrayObject>();
auto code = pending_code.release_value();
for (auto& width : *array)
widths.set(code++, width.to_int());
}
}
}