mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 02:57:44 +00:00
LibPDF: Make SimpleFont font matrix configurable
Type 3 fonts can set it to a custom value.
This commit is contained in:
parent
4cd1a2d319
commit
9632d8ee49
2 changed files with 9 additions and 2 deletions
|
@ -52,11 +52,11 @@ PDFErrorOr<Gfx::FloatPoint> SimpleFont::draw_string(Gfx::Painter& painter, Gfx::
|
|||
// and use the default width for the given font otherwise.
|
||||
float glyph_width;
|
||||
if (auto width = m_widths.get(char_code); width.has_value())
|
||||
glyph_width = font_size * width.value() / 1000.0f;
|
||||
glyph_width = font_size * width.value() * m_font_matrix.x_scale();
|
||||
else if (auto width = get_glyph_width(char_code); width.has_value())
|
||||
glyph_width = width.value();
|
||||
else
|
||||
glyph_width = m_missing_width;
|
||||
glyph_width = m_missing_width; // FIXME: times m_font_matrix.x_scale() probably?
|
||||
|
||||
TRY(draw_glyph(painter, glyph_position, glyph_width, char_code, paint_color));
|
||||
|
||||
|
|
|
@ -22,11 +22,18 @@ protected:
|
|||
RefPtr<Encoding>& encoding() { return m_encoding; }
|
||||
RefPtr<Encoding> const& encoding() const { return m_encoding; }
|
||||
|
||||
Gfx::AffineTransform& font_matrix() { return m_font_matrix; }
|
||||
|
||||
private:
|
||||
RefPtr<Encoding> m_encoding;
|
||||
RefPtr<StreamObject> m_to_unicode;
|
||||
HashMap<u8, u16> m_widths;
|
||||
u16 m_missing_width { 0 };
|
||||
|
||||
// "For all font types except Type 3, the units of glyph space are one-thousandth of a unit of text space;
|
||||
// for a Type 3 font, the transformation from glyph space to text space is defined by a font matrix specified
|
||||
// in an explicit FontMatrix entry in the font."
|
||||
Gfx::AffineTransform m_font_matrix { 1.0f / 1000.0f, 0, 0, 1.0f / 1000.0f, 0, 0 };
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue