mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 18:27:35 +00:00
LibGfx: Add Font::pixel_size_rounded_up()
This returns the font's size (distance between ascender and descender) in pixels, rounded up to the nearest integer. This is the number we want to use in a lot of UI code, so let's have a friendly API for it instead of ceil'ing the pixel_size() in a million random places.
This commit is contained in:
parent
6c8e9fa1b3
commit
93c9344e35
4 changed files with 25 additions and 2 deletions
|
@ -36,7 +36,8 @@ public:
|
|||
virtual NonnullRefPtr<Font> clone() const override { return MUST(try_clone()); } // FIXME: clone() should not need to be implemented
|
||||
virtual ErrorOr<NonnullRefPtr<Font>> try_clone() const override { return const_cast<ScaledFont&>(*this); }
|
||||
virtual u8 presentation_size() const override { return m_point_height; }
|
||||
virtual float pixel_size() const override { return m_point_height * 1.33333333f; }
|
||||
virtual float pixel_size() const override;
|
||||
virtual int pixel_size_rounded_up() const override;
|
||||
virtual Gfx::FontPixelMetrics pixel_metrics() const override;
|
||||
virtual u8 slope() const override { return m_font->slope(); }
|
||||
virtual u16 width() const override { return m_font->width(); }
|
||||
|
@ -80,6 +81,9 @@ private:
|
|||
mutable HashMap<GlyphIndexWithSubpixelOffset, RefPtr<Gfx::Bitmap>> m_cached_glyph_bitmaps;
|
||||
Gfx::FontPixelMetrics m_pixel_metrics;
|
||||
|
||||
float m_pixel_size { 0.0f };
|
||||
int m_pixel_size_rounded_up { 0 };
|
||||
|
||||
template<typename T>
|
||||
float unicode_view_width(T const& view) const;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue