LibPDF: Load Type1C fonts when found

Now that our CFF parser is working we can load Type1C fonts in PDF,
which are backed by a CFF stream.
This commit is contained in:
Rodrigo Tobar 2023-01-15 11:29:12 +08:00 committed by Andreas Kling
parent c4b45a82cd
commit 3588709986
Notes: sideshowbarker 2024-07-17 05:06:13 +09:00
2 changed files with 12 additions and 0 deletions

View file

@ -132,6 +132,7 @@
A(Title) \
A(ToUnicode) \
A(Type) \
A(Type1C) \
A(U) \
A(UCR) \
A(UseBlackPTComp) \

View file

@ -7,6 +7,7 @@
#include <LibGfx/Painter.h>
#include <LibPDF/CommonNames.h>
#include <LibPDF/Fonts/CFF.h>
#include <LibPDF/Fonts/PS1FontProgram.h>
#include <LibPDF/Fonts/Type1Font.h>
@ -19,6 +20,16 @@ PDFErrorOr<Type1Font::Data> Type1Font::parse_data(Document* document, NonnullRef
if (!data.is_standard_font) {
auto descriptor = TRY(dict->get_dict(document, CommonNames::FontDescriptor));
if (descriptor->contains(CommonNames::FontFile3)) {
auto font_file_stream = TRY(descriptor->get_stream(document, CommonNames::FontFile3));
auto font_file_dict = font_file_stream->dict();
if (font_file_dict->contains(CommonNames::Subtype) && font_file_dict->get_name(CommonNames::Subtype)->name() == CommonNames::Type1C) {
data.font_program = TRY(CFF::create(font_file_stream->bytes(), data.encoding));
if (!data.encoding)
data.encoding = data.font_program->encoding();
return data;
}
}
if (!descriptor->contains(CommonNames::FontFile))
return data;