LibPDF: Return an error if we fail to load a replacement font

This commit is contained in:
Julian Offenhäuser 2023-02-11 20:58:14 +01:00 committed by Linus Groh
parent 96064ec5af
commit a2b57dd188
Notes: sideshowbarker 2024-07-17 21:11:12 +09:00

View File

@ -38,7 +38,8 @@ PDFErrorOr<void> PDFFont::CommonData::load_from_dict(Document* document, Nonnull
auto replacement = replacement_for_standard_latin_font(base_font); auto replacement = replacement_for_standard_latin_font(base_font);
float point_size = (font_size * POINTS_PER_INCH) / DEFAULT_DPI; float point_size = (font_size * POINTS_PER_INCH) / DEFAULT_DPI;
font = Gfx::FontDatabase::the().get(replacement.get<0>(), replacement.get<1>(), point_size); font = Gfx::FontDatabase::the().get(replacement.get<0>(), replacement.get<1>(), point_size);
VERIFY(font); if (!font)
return Error(Error::Type::Internal, DeprecatedString::formatted("Failed to load {} {} at {}pt", replacement.get<0>(), replacement.get<1>(), point_size));
} }
if (dict->contains(CommonNames::Encoding)) { if (dict->contains(CommonNames::Encoding)) {