mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 07:47:48 +00:00
LibPDF: Add CIDFontType2::set_font_size()
See #20084 commit 4. This does the same for truetye-based type0 fonts. Fixes font sizes on e.g. 1800-2017.pdf.
This commit is contained in:
parent
f4a59246f5
commit
05f382fc6e
1 changed files with 12 additions and 1 deletions
|
@ -17,6 +17,7 @@ class CIDFontType {
|
||||||
public:
|
public:
|
||||||
virtual ~CIDFontType() = default;
|
virtual ~CIDFontType() = default;
|
||||||
virtual PDFErrorOr<void> draw_glyph(Gfx::Painter&, Gfx::FloatPoint, float width, u32 cid, Renderer const&) = 0;
|
virtual PDFErrorOr<void> draw_glyph(Gfx::Painter&, Gfx::FloatPoint, float width, u32 cid, Renderer const&) = 0;
|
||||||
|
virtual void set_font_size(float) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CIDFontType0 : public CIDFontType {
|
class CIDFontType0 : public CIDFontType {
|
||||||
|
@ -25,6 +26,8 @@ public:
|
||||||
|
|
||||||
virtual PDFErrorOr<void> draw_glyph(Gfx::Painter&, Gfx::FloatPoint, float width, u32 cid, Renderer const&) override;
|
virtual PDFErrorOr<void> draw_glyph(Gfx::Painter&, Gfx::FloatPoint, float width, u32 cid, Renderer const&) override;
|
||||||
|
|
||||||
|
virtual void set_font_size(float) override { }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CIDFontType0(RefPtr<Type1FontProgram> font_program)
|
CIDFontType0(RefPtr<Type1FontProgram> font_program)
|
||||||
: m_font_program(move(font_program))
|
: m_font_program(move(font_program))
|
||||||
|
@ -115,6 +118,8 @@ public:
|
||||||
|
|
||||||
virtual PDFErrorOr<void> draw_glyph(Gfx::Painter&, Gfx::FloatPoint, float width, u32 cid, Renderer const&) override;
|
virtual PDFErrorOr<void> draw_glyph(Gfx::Painter&, Gfx::FloatPoint, float width, u32 cid, Renderer const&) override;
|
||||||
|
|
||||||
|
virtual void set_font_size(float) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CIDFontType2(RefPtr<Gfx::Font> font)
|
CIDFontType2(RefPtr<Gfx::Font> font)
|
||||||
: m_font(move(font))
|
: m_font(move(font))
|
||||||
|
@ -195,6 +200,11 @@ PDFErrorOr<void> CIDFontType2::draw_glyph(Gfx::Painter& painter, Gfx::FloatPoint
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CIDFontType2::set_font_size(float font_size)
|
||||||
|
{
|
||||||
|
m_font = m_font->with_size((font_size * POINTS_PER_INCH) / DEFAULT_DPI);
|
||||||
|
}
|
||||||
|
|
||||||
Type0Font::Type0Font() = default;
|
Type0Font::Type0Font() = default;
|
||||||
Type0Font::~Type0Font() = default;
|
Type0Font::~Type0Font() = default;
|
||||||
|
|
||||||
|
@ -283,8 +293,9 @@ float Type0Font::get_char_width(u16 char_code) const
|
||||||
return static_cast<float>(width) / 1000.0f;
|
return static_cast<float>(width) / 1000.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Type0Font::set_font_size(float)
|
void Type0Font::set_font_size(float font_size)
|
||||||
{
|
{
|
||||||
|
m_cid_font_type->set_font_size(font_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
PDFErrorOr<Gfx::FloatPoint> Type0Font::draw_string(Gfx::Painter& painter, Gfx::FloatPoint glyph_position, ByteString const& string, Renderer const& renderer)
|
PDFErrorOr<Gfx::FloatPoint> Type0Font::draw_string(Gfx::Painter& painter, Gfx::FloatPoint glyph_position, ByteString const& string, Renderer const& renderer)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue