mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 07:37:46 +00:00
LibPDF: Checking for built-in CFF encodings
Only prints a warning for them for now. Also warn on the not-yet-implemented encoding supplement.
This commit is contained in:
parent
414a164850
commit
96a4936567
1 changed files with 19 additions and 2 deletions
|
@ -115,9 +115,21 @@ PDFErrorOr<NonnullRefPtr<CFF>> CFF::create(ReadonlyBytes const& cff_bytes, RefPt
|
||||||
auto encoding_offset = 0;
|
auto encoding_offset = 0;
|
||||||
if (!operands.is_empty())
|
if (!operands.is_empty())
|
||||||
encoding_offset = operands[0].get<int>();
|
encoding_offset = operands[0].get<int>();
|
||||||
|
|
||||||
|
// CFF spec, "Table 16 Encoding ID"
|
||||||
|
switch (encoding_offset) {
|
||||||
|
case 0:
|
||||||
|
dbgln("CFF: Built-in Standard Encoding not yet implemented");
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
dbgln("CFF: Built-in Expert Encoding not yet implemented");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
encoding_codes = TRY(parse_encoding(Reader(cff_bytes.slice(encoding_offset))));
|
encoding_codes = TRY(parse_encoding(Reader(cff_bytes.slice(encoding_offset))));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
case TopDictOperator::Charset: {
|
case TopDictOperator::Charset: {
|
||||||
if (!operands.is_empty())
|
if (!operands.is_empty())
|
||||||
charset_offset = operands[0].get<int>();
|
charset_offset = operands[0].get<int>();
|
||||||
|
@ -704,7 +716,7 @@ PDFErrorOr<Vector<u8>> CFF::parse_encoding(Reader&& reader)
|
||||||
// CFF spec, "12 Encodings"
|
// CFF spec, "12 Encodings"
|
||||||
Vector<u8> encoding_codes;
|
Vector<u8> encoding_codes;
|
||||||
auto format_raw = TRY(reader.try_read<Card8>());
|
auto format_raw = TRY(reader.try_read<Card8>());
|
||||||
// TODO: support encoding supplements when highest bit is set
|
|
||||||
auto format = format_raw & 0x7f;
|
auto format = format_raw & 0x7f;
|
||||||
if (format == 0) {
|
if (format == 0) {
|
||||||
auto n_codes = TRY(reader.try_read<Card8>());
|
auto n_codes = TRY(reader.try_read<Card8>());
|
||||||
|
@ -722,6 +734,11 @@ PDFErrorOr<Vector<u8>> CFF::parse_encoding(Reader&& reader)
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
return error(DeprecatedString::formatted("Invalid encoding format: {}", format));
|
return error(DeprecatedString::formatted("Invalid encoding format: {}", format));
|
||||||
|
|
||||||
|
// TODO: support encoding supplements when highest bit is set (tables 14 and 15).
|
||||||
|
if (format_raw & 0x80)
|
||||||
|
dbgln("CFF: Support for multiply-encoded glyphs not yet implemented");
|
||||||
|
|
||||||
return encoding_codes;
|
return encoding_codes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue