diff options
-rw-r--r-- | Userland/Libraries/LibGfx/Font/BitmapFont.cpp | 5 | ||||
-rw-r--r-- | Userland/Libraries/LibGfx/Font/BitmapFont.h | 2 | ||||
-rw-r--r-- | Userland/Libraries/LibGfx/Font/Font.h | 2 | ||||
-rw-r--r-- | Userland/Libraries/LibGfx/Font/ScaledFont.cpp | 5 | ||||
-rw-r--r-- | Userland/Libraries/LibGfx/Font/ScaledFont.h | 2 |
5 files changed, 16 insertions, 0 deletions
diff --git a/Userland/Libraries/LibGfx/Font/BitmapFont.cpp b/Userland/Libraries/LibGfx/Font/BitmapFont.cpp index 3f56571d98..6aabeefebb 100644 --- a/Userland/Libraries/LibGfx/Font/BitmapFont.cpp +++ b/Userland/Libraries/LibGfx/Font/BitmapFont.cpp @@ -381,6 +381,11 @@ DeprecatedString BitmapFont::variant() const return builder.to_deprecated_string(); } +RefPtr<Font> BitmapFont::with_size(float point_size) const +{ + return Gfx::FontDatabase::the().get(family(), point_size, weight(), width(), slope()); +} + Font const& Font::bold_variant() const { if (m_bold_variant) diff --git a/Userland/Libraries/LibGfx/Font/BitmapFont.h b/Userland/Libraries/LibGfx/Font/BitmapFont.h index 0bb57cce95..62c22871d8 100644 --- a/Userland/Libraries/LibGfx/Font/BitmapFont.h +++ b/Userland/Libraries/LibGfx/Font/BitmapFont.h @@ -125,6 +125,8 @@ public: DeprecatedString qualified_name() const override; DeprecatedString human_readable_name() const override { return DeprecatedString::formatted("{} {} {}", family(), variant(), presentation_size()); } + virtual RefPtr<Font> with_size(float point_size) const override; + private: BitmapFont(DeprecatedString name, DeprecatedString family, u8* rows, u8* widths, bool is_fixed_width, u8 glyph_width, u8 glyph_height, u8 glyph_spacing, u16 range_mask_size, u8* range_mask, diff --git a/Userland/Libraries/LibGfx/Font/Font.h b/Userland/Libraries/LibGfx/Font/Font.h index f26a432d7c..5e18cfd53b 100644 --- a/Userland/Libraries/LibGfx/Font/Font.h +++ b/Userland/Libraries/LibGfx/Font/Font.h @@ -197,6 +197,8 @@ public: virtual DeprecatedString qualified_name() const = 0; virtual DeprecatedString human_readable_name() const = 0; + virtual RefPtr<Font> with_size(float point_size) const = 0; + Font const& bold_variant() const; private: diff --git a/Userland/Libraries/LibGfx/Font/ScaledFont.cpp b/Userland/Libraries/LibGfx/Font/ScaledFont.cpp index 5e4040c235..9cb6fdf37c 100644 --- a/Userland/Libraries/LibGfx/Font/ScaledFont.cpp +++ b/Userland/Libraries/LibGfx/Font/ScaledFont.cpp @@ -123,6 +123,11 @@ u8 ScaledFont::glyph_fixed_width() const return glyph_metrics(glyph_id_for_code_point(' ')).advance_width; } +RefPtr<Font> ScaledFont::with_size(float point_size) const +{ + return adopt_ref(*new Gfx::ScaledFont(*m_font, point_size, point_size)); +} + Gfx::FontPixelMetrics ScaledFont::pixel_metrics() const { return m_pixel_metrics; diff --git a/Userland/Libraries/LibGfx/Font/ScaledFont.h b/Userland/Libraries/LibGfx/Font/ScaledFont.h index e1379cdcf1..b87a5095b4 100644 --- a/Userland/Libraries/LibGfx/Font/ScaledFont.h +++ b/Userland/Libraries/LibGfx/Font/ScaledFont.h @@ -67,6 +67,8 @@ public: virtual DeprecatedString qualified_name() const override { return DeprecatedString::formatted("{} {} {} {}", family(), presentation_size(), weight(), slope()); } virtual DeprecatedString human_readable_name() const override { return DeprecatedString::formatted("{} {} {}", family(), variant(), presentation_size()); } + virtual RefPtr<Font> with_size(float point_size) const override; + private: NonnullRefPtr<VectorFont> m_font; float m_x_scale { 0.0f }; |