1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 14:57:35 +00:00

LibPDF: Add some spec comments in Type0Font::initialize()

This commit is contained in:
Nico Weber 2024-03-01 08:45:08 -05:00 committed by Andreas Kling
parent 004e47df88
commit fc9b2440bd

View file

@ -273,12 +273,14 @@ PDFErrorOr<void> Type0Font::initialize(Document* document, NonnullRefPtr<DictObj
return Error { Error::Type::MalformedPDF, "invalid /Subtype for Type 0 font" }; return Error { Error::Type::MalformedPDF, "invalid /Subtype for Type 0 font" };
} }
// PDF 1.7 spec, 5.6.3 CIDFonts, Glyph Metrics in CIDFonts, and TABLE 5.14 Entries in a CIDFont dictionary
// "The DW entry defines the default width, which is used for all glyphs whose widths are not specified individually."
u16 default_width = 1000; u16 default_width = 1000;
if (descendant_font->contains(CommonNames::DW)) if (descendant_font->contains(CommonNames::DW))
default_width = descendant_font->get_value(CommonNames::DW).to_int(); default_width = descendant_font->get_value(CommonNames::DW).to_int();
// "The W array allows the definition of widths for individual CIDs."
HashMap<u16, u16> widths; HashMap<u16, u16> widths;
if (descendant_font->contains(CommonNames::W)) { if (descendant_font->contains(CommonNames::W)) {
auto widths_array = MUST(descendant_font->get_array(document, CommonNames::W)); auto widths_array = MUST(descendant_font->get_array(document, CommonNames::W));
Optional<u16> pending_code; Optional<u16> pending_code;