mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 11:07:45 +00:00
LibGfx: Add Font::pixel_size() and Font::point_size()
We've gotten ourselves into a bit of a mess by mixing pixel and point sizes in multiple places. Step one towards getting out of this mess is adding explicit accessors for the unit you're trying to fetch. The core of the issue comes from bitmap fonts storing integer pixel sizes and scaled (TTF) fonts storing float point sizes.
This commit is contained in:
parent
d5bba91a16
commit
ff951c89fe
3 changed files with 7 additions and 0 deletions
|
@ -37,6 +37,9 @@ public:
|
||||||
u8 presentation_size() const override { return m_presentation_size; }
|
u8 presentation_size() const override { return m_presentation_size; }
|
||||||
void set_presentation_size(u8 size) { m_presentation_size = size; }
|
void set_presentation_size(u8 size) { m_presentation_size = size; }
|
||||||
|
|
||||||
|
virtual int pixel_size() const override { return m_glyph_height; }
|
||||||
|
virtual float point_size() const override { return static_cast<float>(m_glyph_height) * 0.75f; }
|
||||||
|
|
||||||
u16 weight() const override { return m_weight; }
|
u16 weight() const override { return m_weight; }
|
||||||
void set_weight(u16 weight) { m_weight = weight; }
|
void set_weight(u16 weight) { m_weight = weight; }
|
||||||
|
|
||||||
|
|
|
@ -106,6 +106,8 @@ public:
|
||||||
FontMetrics metrics(u32 code_point) const;
|
FontMetrics metrics(u32 code_point) const;
|
||||||
|
|
||||||
virtual u8 presentation_size() const = 0;
|
virtual u8 presentation_size() const = 0;
|
||||||
|
virtual int pixel_size() const = 0;
|
||||||
|
virtual float point_size() const = 0;
|
||||||
virtual u8 slope() const = 0;
|
virtual u8 slope() const = 0;
|
||||||
|
|
||||||
virtual u16 weight() const = 0;
|
virtual u16 weight() const = 0;
|
||||||
|
|
|
@ -126,6 +126,8 @@ public:
|
||||||
// Gfx::Font implementation
|
// Gfx::Font implementation
|
||||||
virtual NonnullRefPtr<Font> clone() const override { return *this; } // FIXME: clone() should not need to be implemented
|
virtual NonnullRefPtr<Font> clone() const override { return *this; } // FIXME: clone() should not need to be implemented
|
||||||
virtual u8 presentation_size() const override { return m_point_height; }
|
virtual u8 presentation_size() const override { return m_point_height; }
|
||||||
|
virtual int pixel_size() const override { return m_point_height * 1.33333333f; }
|
||||||
|
virtual float point_size() const override { return m_point_height; }
|
||||||
virtual u8 slope() const override { return m_font->slope(); }
|
virtual u8 slope() const override { return m_font->slope(); }
|
||||||
virtual u16 weight() const override { return m_font->weight(); }
|
virtual u16 weight() const override { return m_font->weight(); }
|
||||||
virtual Gfx::Glyph glyph(u32 code_point) const override;
|
virtual Gfx::Glyph glyph(u32 code_point) const override;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue