From 095a2a17eda4d2ba4213dfc589d98009a285f211 Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Fri, 20 Oct 2023 10:09:50 -0400 Subject: [PATCH] LibPDF: Replace TODO()s in Type0Font code with Errors ...which causes us to not render these fonts instead of crashing. Reduces number of crashes on 300 random PDFs from the web (the first 300 from 0000.zip from https://pdfa.org/new-large-scale-pdf-corpus-now-publicly-available/) from 64 (21%) to 42 (14%). --- Userland/Libraries/LibPDF/Fonts/Type0Font.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Userland/Libraries/LibPDF/Fonts/Type0Font.cpp b/Userland/Libraries/LibPDF/Fonts/Type0Font.cpp index 47f2ba84b44..47429259655 100644 --- a/Userland/Libraries/LibPDF/Fonts/Type0Font.cpp +++ b/Userland/Libraries/LibPDF/Fonts/Type0Font.cpp @@ -49,9 +49,9 @@ PDFErrorOr> CIDFontType2::create(Document* document, if (descendant->contains(CommonNames::CIDToGIDMap)) { auto value = TRY(descendant->get_object(document, CommonNames::CIDToGIDMap)); if (value->is()) { - TODO(); + return Error::rendering_unsupported_error("Type0 font subtype 2: support for stream cid maps not yet implemented"); } else if (value->cast()->name() != "Identity") { - TODO(); + return Error::rendering_unsupported_error("Type0 font: support for non-Identity named cid maps not yet implemented"); } } @@ -98,7 +98,7 @@ PDFErrorOr Type0Font::initialize(Document* document, NonnullRefPtrget_object(document, CommonNames::Encoding)); if (!cmap_value->is() || cmap_value->cast()->name() != CommonNames::IdentityH) - TODO(); + return Error::rendering_unsupported_error("Type0 font: support for general Encodings not yet implemented"); auto descendant_font_value = TRY(dict->get_array(document, CommonNames::DescendantFonts)); auto descendant_font = TRY(descendant_font_value->get_dict_at(document, 0));