mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-30 08:41:15 +00:00
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:
parent
c4b45a82cd
commit
3588709986
Notes:
sideshowbarker
2024-07-17 05:06:13 +09:00
Author: https://github.com/rtobar Commit: https://github.com/SerenityOS/serenity/commit/3588709986 Pull-request: https://github.com/SerenityOS/serenity/pull/17082
|
@ -132,6 +132,7 @@
|
|||
A(Title) \
|
||||
A(ToUnicode) \
|
||||
A(Type) \
|
||||
A(Type1C) \
|
||||
A(U) \
|
||||
A(UCR) \
|
||||
A(UseBlackPTComp) \
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
Loading…
Reference in a new issue