1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-15 01:34:59 +00:00

LibPDF: Implement support for CFF charset format 2

I haven't seen this being used in the wild (yet), but it's easy
to implement, and with this we support all charset formats.

So we can now mention if we see a format we don't know about.
This commit is contained in:
Nico Weber 2023-10-13 10:34:27 -04:00 committed by Jelle Raaijmakers
parent 5b915fb15c
commit 6f783929dd

View file

@ -637,6 +637,18 @@ PDFErrorOr<Vector<DeprecatedFlyString>> CFF::parse_charset(Reader&& reader, size
for (SID sid = first_sid; left >= 0; left--, sid++)
TRY(names.try_append(resolve_sid(sid, strings)));
}
} else if (format == 2) {
// CFF spec, "Table 20 Format 2"
// "Format 2 differs from format 1 only in the size of the Left field in each range."
while (names.size() < glyph_count - 1) {
// CFF spec, "Table 21 Range2 Format"
auto first_sid = TRY(reader.try_read<BigEndian<SID>>());
int left = TRY(reader.try_read<Card16>());
for (SID sid = first_sid; left >= 0; left--, sid++)
TRY(names.try_append(resolve_sid(sid, strings)));
}
} else {
dbgln("CFF: Unknown charset format {}", format);
}
return names;
}