diff options
author | Rodrigo Tobar <rtobarc@gmail.com> | 2023-01-15 11:29:12 +0800 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2023-01-25 15:40:11 +0100 |
commit | 358870998684a1b30e7f79f60fa55e30754bcb32 (patch) | |
tree | 7510969b21712c557c464f184678906a3eda9ab6 /Userland/Libraries/LibPDF | |
parent | c4b45a82cd98821b31e48b00520eccc81907c9c9 (diff) | |
download | serenity-358870998684a1b30e7f79f60fa55e30754bcb32.zip |
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.
Diffstat (limited to 'Userland/Libraries/LibPDF')
-rw-r--r-- | Userland/Libraries/LibPDF/CommonNames.h | 1 | ||||
-rw-r--r-- | Userland/Libraries/LibPDF/Fonts/Type1Font.cpp | 11 |
2 files changed, 12 insertions, 0 deletions
diff --git a/Userland/Libraries/LibPDF/CommonNames.h b/Userland/Libraries/LibPDF/CommonNames.h index 907f3ff524..33a487733d 100644 --- a/Userland/Libraries/LibPDF/CommonNames.h +++ b/Userland/Libraries/LibPDF/CommonNames.h @@ -132,6 +132,7 @@ A(Title) \ A(ToUnicode) \ A(Type) \ + A(Type1C) \ A(U) \ A(UCR) \ A(UseBlackPTComp) \ diff --git a/Userland/Libraries/LibPDF/Fonts/Type1Font.cpp b/Userland/Libraries/LibPDF/Fonts/Type1Font.cpp index 76ff822a52..fd93c815de 100644 --- a/Userland/Libraries/LibPDF/Fonts/Type1Font.cpp +++ b/Userland/Libraries/LibPDF/Fonts/Type1Font.cpp @@ -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; |