1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 12:37:44 +00:00

LibPDF: Be louder about unimplemented CFF dict entries

This commit is contained in:
Nico Weber 2023-10-12 10:32:36 -04:00 committed by Andreas Kling
parent c825194fb9
commit 414a164850
2 changed files with 46 additions and 8 deletions

View file

@ -81,6 +81,36 @@ PDFErrorOr<NonnullRefPtr<CFF>> CFF::create(ReadonlyBytes const& cff_bytes, RefPt
Reader element_reader { element_data }; Reader element_reader { element_data };
return parse_dict<TopDictOperator>(element_reader, [&](TopDictOperator op, Vector<DictOperand> const& operands) -> PDFErrorOr<void> { return parse_dict<TopDictOperator>(element_reader, [&](TopDictOperator op, Vector<DictOperand> const& operands) -> PDFErrorOr<void> {
switch (op) { switch (op) {
case TopDictOperator::Version:
case TopDictOperator::Notice:
case TopDictOperator::FullName:
case TopDictOperator::FamilyName:
case TopDictOperator::Weight:
case TopDictOperator::FontBBox:
case TopDictOperator::UniqueID:
case TopDictOperator::XUID:
case TopDictOperator::IsFixedPitch:
case TopDictOperator::ItalicAngle:
case TopDictOperator::UnderlinePosition:
case TopDictOperator::UnderlineThickness:
case TopDictOperator::PaintType:
case TopDictOperator::FontMatrix:
case TopDictOperator::StrokeWidth:
case TopDictOperator::PostScript:
case TopDictOperator::BaseFontName:
case TopDictOperator::BaseFontBlend:
break;
case TopDictOperator::CharstringType: {
int charstring_type = 2;
if (!operands.is_empty())
charstring_type = operands[0].get<int>();
if (charstring_type != 2)
dbgln("CFF: has unimplemented CharstringType, might not look right");
break;
}
case TopDictOperator::SyntheticBase:
dbgln("CFF: has unimplemented SyntheticBase, might not look right");
break;
case TopDictOperator::Encoding: { case TopDictOperator::Encoding: {
auto encoding_offset = 0; auto encoding_offset = 0;
if (!operands.is_empty()) if (!operands.is_empty())
@ -128,7 +158,8 @@ PDFErrorOr<NonnullRefPtr<CFF>> CFF::create(ReadonlyBytes const& cff_bytes, RefPt
})); }));
break; break;
} }
default:; default:
dbgln("CFF: Unhandled top dict entry {}", static_cast<int>(op));
} }
return {}; return {};
}); });

View file

@ -28,17 +28,24 @@ private:
FamilyName, FamilyName,
Weight, Weight,
FontBBox, FontBBox,
// UniqueID = 13, UniqueID = 13,
// XUID, XUID,
Charset = 15, Charset = 15,
Encoding, Encoding,
CharStrings, CharStrings,
Private, Private,
// IsFixedPitch = (12 << 8 | 1), IsFixedPitch = (12 << 8 | 1),
// ItalicAngle, ItalicAngle,
// UnderlinePosition, UnderlinePosition,
// UnderlineThickness, UnderlineThickness,
// PaintType, PaintType,
CharstringType,
FontMatrix,
StrokeWidth,
SyntheticBase = (12 << 8 | 20),
PostScript,
BaseFontName,
BaseFontBlend,
}; };
// CFF spec, "Table 23 Private DICT Operators" // CFF spec, "Table 23 Private DICT Operators"