mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 09:48:11 +00:00
LibPDF: Add very basic support for Adobe Type 1 font rendering
Previously we would draw all text, no matter what font type, as Liberation Serif, which results in things like ugly character spacing. We now have partial support for drawing Type 1 glyphs, which are part of a PostScript font program. We completely ignore hinting for now, which results in ugly looking characters at low resolutions, but gain support for a large number of typefaces, including most of the default fonts used in TeX.
This commit is contained in:
parent
e6f29302a7
commit
b14f0950a5
9 changed files with 752 additions and 16 deletions
|
@ -11,6 +11,17 @@
|
|||
|
||||
namespace PDF {
|
||||
|
||||
PDFErrorOr<NonnullRefPtr<Encoding>> Encoding::create(HashMap<u16, CharDescriptor> descriptors)
|
||||
{
|
||||
auto encoding = adopt_ref(*new Encoding());
|
||||
encoding->m_descriptors = descriptors;
|
||||
|
||||
for (auto& descriptor : descriptors)
|
||||
encoding->m_name_mapping.set(descriptor.value.name, descriptor.value.code_point);
|
||||
|
||||
return encoding;
|
||||
}
|
||||
|
||||
PDFErrorOr<NonnullRefPtr<Encoding>> Encoding::from_object(Document* document, NonnullRefPtr<Object> const& obj)
|
||||
{
|
||||
if (obj->is<NameObject>()) {
|
||||
|
@ -37,8 +48,9 @@ PDFErrorOr<NonnullRefPtr<Encoding>> Encoding::from_object(Document* document, No
|
|||
}
|
||||
|
||||
auto encoding = adopt_ref(*new Encoding());
|
||||
for (auto& [code_point, descriptor] : base_encoding->descriptors())
|
||||
encoding->m_descriptors.set(code_point, descriptor);
|
||||
|
||||
encoding->m_descriptors = base_encoding->descriptors();
|
||||
encoding->m_name_mapping = base_encoding->name_mapping();
|
||||
|
||||
auto differences_array = TRY(dict->get_array(document, CommonNames::Differences));
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue