mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 05:37:34 +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
2 changed files with 12 additions and 0 deletions
|
@ -132,6 +132,7 @@
|
||||||
A(Title) \
|
A(Title) \
|
||||||
A(ToUnicode) \
|
A(ToUnicode) \
|
||||||
A(Type) \
|
A(Type) \
|
||||||
|
A(Type1C) \
|
||||||
A(U) \
|
A(U) \
|
||||||
A(UCR) \
|
A(UCR) \
|
||||||
A(UseBlackPTComp) \
|
A(UseBlackPTComp) \
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
|
|
||||||
#include <LibGfx/Painter.h>
|
#include <LibGfx/Painter.h>
|
||||||
#include <LibPDF/CommonNames.h>
|
#include <LibPDF/CommonNames.h>
|
||||||
|
#include <LibPDF/Fonts/CFF.h>
|
||||||
#include <LibPDF/Fonts/PS1FontProgram.h>
|
#include <LibPDF/Fonts/PS1FontProgram.h>
|
||||||
#include <LibPDF/Fonts/Type1Font.h>
|
#include <LibPDF/Fonts/Type1Font.h>
|
||||||
|
|
||||||
|
@ -19,6 +20,16 @@ PDFErrorOr<Type1Font::Data> Type1Font::parse_data(Document* document, NonnullRef
|
||||||
|
|
||||||
if (!data.is_standard_font) {
|
if (!data.is_standard_font) {
|
||||||
auto descriptor = TRY(dict->get_dict(document, CommonNames::FontDescriptor));
|
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))
|
if (!descriptor->contains(CommonNames::FontFile))
|
||||||
return data;
|
return data;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue