From 46fd6fdfa39778d8863a1705ab791e1a5dbe1e32 Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Tue, 17 Oct 2023 09:42:21 -0400 Subject: [PATCH] LibPDF: Read Global subr data in CFF reader This was the last piece of data we didn't read yet. (We also don't yet support multiple fonts per CFF, but I haven't found a PDF using that yet.) We still don't do anything with it, but now we at least print a warning if this data is there and we ignore it. --- Userland/Libraries/LibPDF/Fonts/CFF.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Userland/Libraries/LibPDF/Fonts/CFF.cpp b/Userland/Libraries/LibPDF/Fonts/CFF.cpp index 31f7285524..4bd93c65fe 100644 --- a/Userland/Libraries/LibPDF/Fonts/CFF.cpp +++ b/Userland/Libraries/LibPDF/Fonts/CFF.cpp @@ -216,8 +216,14 @@ PDFErrorOr> CFF::create(ReadonlyBytes const& cff_bytes, RefPt auto strings = TRY(parse_strings(reader)); - // FIXME: CFF spec "16 Local/Global Subrs INDEXes" - // "Global subrs are stored in an INDEX structure which follows the String INDEX." + // CFF spec "16 Local/Global Subrs INDEXes" + // "Global subrs are stored in an INDEX structure which follows the String INDEX." + Vector global_subroutines; + TRY(parse_index(reader, [&](ReadonlyBytes const& subroutine_bytes) -> PDFErrorOr { + return TRY(global_subroutines.try_append(TRY(ByteBuffer::copy(subroutine_bytes)))); + })); + if (!global_subroutines.is_empty()) + dbgln("CFF data contains Global subrs, which aren't implemented yet"); // FIXME // Create glyphs (now that we have the subroutines) and associate missing information to store them and their encoding auto glyphs = TRY(parse_charstrings(Reader(cff_bytes.slice(charstrings_offset)), local_subroutines));