From f0e7fb7038521543114b8cdbd5fa9ecb8e5e8a90 Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Tue, 17 Oct 2023 15:54:42 -0400 Subject: [PATCH] LibPDF: Make Subrs optional in PS1FontProgram https://adobe-type-tools.github.io/font-tech-notes/pdfs/T1_SPEC.pdf : "Using charstring subroutines is not a requirement of a Type 1 font program." And some versions of Computer Modern do in fact not contain a Subrs array. Together with #21473, makes Problemset.pdf from the pdffiles repro render ok instead of crashing. --- Userland/Libraries/LibPDF/Fonts/PS1FontProgram.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Userland/Libraries/LibPDF/Fonts/PS1FontProgram.cpp b/Userland/Libraries/LibPDF/Fonts/PS1FontProgram.cpp index a4a5000ef3..f46f4ab673 100644 --- a/Userland/Libraries/LibPDF/Fonts/PS1FontProgram.cpp +++ b/Userland/Libraries/LibPDF/Fonts/PS1FontProgram.cpp @@ -70,9 +70,9 @@ PDFErrorOr PS1FontProgram::parse_encrypted_portion(ByteBuffer const& buffe if (seek_name(reader, "lenIV")) m_lenIV = TRY(parse_int(reader)); - if (!seek_name(reader, "Subrs")) - return error("Missing subroutine array"); - auto subroutines = TRY(parse_subroutines(reader)); + Vector subroutines; + if (seek_name(reader, "Subrs")) + subroutines = TRY(parse_subroutines(reader)); if (!seek_name(reader, "CharStrings")) return error("Missing char strings array");