From 23d130477962da41b4bdabc963ea67070c0287b3 Mon Sep 17 00:00:00 2001 From: Sadie del Solar Date: Fri, 7 Jun 2024 15:11:45 -0700 Subject: [PATCH] Codechange: Expose SetFontSize in Fontcache class. --- src/fontcache.cpp | 5 +++++ src/fontcache.h | 2 ++ src/fontcache/freetypefontcache.cpp | 5 +++-- src/os/macosx/font_osx.cpp | 2 ++ src/os/windows/font_win32.cpp | 2 ++ 5 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/fontcache.cpp b/src/fontcache.cpp index 46bcb9769c..80972fc722 100644 --- a/src/fontcache.cpp +++ b/src/fontcache.cpp @@ -55,6 +55,11 @@ int FontCache::GetDefaultFontHeight(FontSize fs) return _default_font_height[fs]; } +void FontCache::SetFontSize([[maybe_unused]] int pixels) +{ + Debug(fontcache, 0, "Font {} isn't resizable.", this->GetFontName()); +} + /** * Get the font name of a given font size. * @param fs The font size to look up. diff --git a/src/fontcache.h b/src/fontcache.h index 1050420ee4..5e64378d21 100644 --- a/src/fontcache.h +++ b/src/fontcache.h @@ -65,6 +65,8 @@ public: */ virtual int GetFontSize() const { return this->height; } + virtual void SetFontSize([[maybe_unused]] int pixels); + /** * Map a SpriteID to the key * @param key The key to map to. diff --git a/src/fontcache/freetypefontcache.cpp b/src/fontcache/freetypefontcache.cpp index 9c9ccaaeeb..06ee700b52 100644 --- a/src/fontcache/freetypefontcache.cpp +++ b/src/fontcache/freetypefontcache.cpp @@ -32,8 +32,6 @@ class FreeTypeFontCache : public TrueTypeFontCache { private: FT_Face face; ///< The font face associated with this font. - - void SetFontSize(int pixels); const Sprite *InternalGetGlyph(GlyphID key, bool aa) override; public: @@ -44,6 +42,7 @@ public: std::string GetFontName() override { return fmt::format("{}, {}", face->family_name, face->style_name); } bool IsBuiltInFont() override { return false; } const void *GetOSHandle() override { return &face; } + void SetFontSize(int pixels) override; }; FT_Library _library = nullptr; @@ -64,6 +63,8 @@ FreeTypeFontCache::FreeTypeFontCache(FontSize fs, FT_Face face, int pixels) : Tr void FreeTypeFontCache::SetFontSize(int pixels) { + this->req_size = pixels; + if (pixels == 0) { /* Try to determine a good height based on the minimal height recommended by the font. */ int scaled_height = ScaleGUITrad(FontCache::GetDefaultFontHeight(this->fs)); diff --git a/src/os/macosx/font_osx.cpp b/src/os/macosx/font_osx.cpp index 5d8b79e1be..bad76e440a 100644 --- a/src/os/macosx/font_osx.cpp +++ b/src/os/macosx/font_osx.cpp @@ -126,6 +126,8 @@ void CoreTextFontCache::ClearFontCache() void CoreTextFontCache::SetFontSize(int pixels) { + this->req_size = pixels; + if (pixels == 0) { /* Try to determine a good height based on the height recommended by the font. */ int scaled_height = ScaleGUITrad(FontCache::GetDefaultFontHeight(this->fs)); diff --git a/src/os/windows/font_win32.cpp b/src/os/windows/font_win32.cpp index 6f021c270a..94d83e73bc 100644 --- a/src/os/windows/font_win32.cpp +++ b/src/os/windows/font_win32.cpp @@ -121,6 +121,8 @@ Win32FontCache::~Win32FontCache() void Win32FontCache::SetFontSize(int pixels) { + this->req_size = pixels; + if (pixels == 0) { /* Try to determine a good height based on the minimal height recommended by the font. */ int scaled_height = ScaleGUITrad(FontCache::GetDefaultFontHeight(this->fs));