diff options
author | Julian Offenhäuser <metalvoidzz@gmail.com> | 2022-08-19 19:42:07 +0200 |
---|---|---|
committer | Sam Atkins <atkinssj@gmail.com> | 2022-09-17 10:07:14 +0100 |
commit | 36828f1385c37d8639fc25b4de1f2153e76d465d (patch) | |
tree | ea3990627cf8945e6a9cef22f79dc0ac113f8e72 /Userland/Libraries | |
parent | 97ed4106e5203ffd6b5806ba58a94c9b6ca69504 (diff) | |
download | serenity-36828f1385c37d8639fc25b4de1f2153e76d465d.zip |
LibPDF: Don't expect glyph width arrays to contain integers
They might also contain floats, in which case we convert them to int
before use.
Diffstat (limited to 'Userland/Libraries')
-rw-r--r-- | Userland/Libraries/LibPDF/Fonts/Type0Font.cpp | 10 | ||||
-rw-r--r-- | Userland/Libraries/LibPDF/Fonts/Type1Font.cpp | 4 |
2 files changed, 7 insertions, 7 deletions
diff --git a/Userland/Libraries/LibPDF/Fonts/Type0Font.cpp b/Userland/Libraries/LibPDF/Fonts/Type0Font.cpp index d7921a74d6..dbebb02610 100644 --- a/Userland/Libraries/LibPDF/Fonts/Type0Font.cpp +++ b/Userland/Libraries/LibPDF/Fonts/Type0Font.cpp @@ -29,7 +29,7 @@ PDFErrorOr<NonnullRefPtr<Type0Font>> Type0Font::create(Document* document, Nonnu u16 default_width = 1000; if (descendant_font->contains(CommonNames::DW)) - default_width = descendant_font->get_value(CommonNames::DW).get<int>(); + default_width = descendant_font->get_value(CommonNames::DW).to_int(); HashMap<u16, u16> widths; @@ -40,16 +40,16 @@ PDFErrorOr<NonnullRefPtr<Type0Font>> Type0Font::create(Document* document, Nonnu for (size_t i = 0; i < widths_array->size(); i++) { auto& value = widths_array->at(i); if (!pending_code.has_value()) { - pending_code = value.get<int>(); + 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.get<int>()); + widths.set(code++, width.to_int()); } else { auto first_code = pending_code.release_value(); - auto last_code = value.get<int>(); - auto width = widths_array->at(i + 1).get<int>(); + auto last_code = value.to_int(); + auto width = widths_array->at(i + 1).to_int(); for (u16 code = first_code; code <= last_code; code++) widths.set(code, width); diff --git a/Userland/Libraries/LibPDF/Fonts/Type1Font.cpp b/Userland/Libraries/LibPDF/Fonts/Type1Font.cpp index d44de2f968..cd95238182 100644 --- a/Userland/Libraries/LibPDF/Fonts/Type1Font.cpp +++ b/Userland/Libraries/LibPDF/Fonts/Type1Font.cpp @@ -61,12 +61,12 @@ PDFErrorOr<Type1Font::Data> Type1Font::parse_data(Document* document, NonnullRef HashMap<u16, u16> widths; for (size_t i = 0; i < widths_array->size(); i++) - widths.set(first_char + i, widths_array->at(i).get<int>()); + widths.set(first_char + i, widths_array->at(i).to_int()); u16 missing_width = 0; auto descriptor = MUST(dict->get_dict(document, CommonNames::FontDescriptor)); if (descriptor->contains(CommonNames::MissingWidth)) - missing_width = descriptor->get_value(CommonNames::MissingWidth).get<int>(); + missing_width = descriptor->get_value(CommonNames::MissingWidth).to_int(); return Type1Font::Data { to_unicode, encoding.release_nonnull(), move(widths), missing_width }; } |