LibPDF: Tolerate integer outline item colors

0000296.pdf from 0000.zip from the pdfa dataset contains
`/C [0 0 0]` (as opposed to `/C [0.0 0.0 0.0]`). Make that work.
(It's fine per spec.)
This commit is contained in:
Nico Weber 2023-10-24 20:17:12 -07:00 committed by Andreas Kling
parent c2c37de201
commit 208a058eab
Notes: sideshowbarker 2024-07-16 22:17:03 +09:00

View file

@ -568,9 +568,9 @@ PDFErrorOr<NonnullRefPtr<OutlineItem>> Document::build_outline_item(NonnullRefPt
if (outline_item_dict->contains(CommonNames::C)) {
auto color_array = TRY(outline_item_dict->get_array(this, CommonNames::C));
auto r = static_cast<int>(255.0f * color_array->at(0).get<float>());
auto g = static_cast<int>(255.0f * color_array->at(1).get<float>());
auto b = static_cast<int>(255.0f * color_array->at(2).get<float>());
auto r = static_cast<int>(255.0f * color_array->at(0).to_float());
auto g = static_cast<int>(255.0f * color_array->at(1).to_float());
auto b = static_cast<int>(255.0f * color_array->at(2).to_float());
outline_item->color = Color(r, g, b);
}