From d78f39a9df2cb42a519ef8a5077beb116e208a98 Mon Sep 17 00:00:00 2001 From: Peter Nelson Date: Sat, 11 May 2024 14:50:34 +0100 Subject: [PATCH] Cleanup: Remove GetUnitsPerEM and units_per_em. (#12656) GetUnitsPerEM is never called. --- src/fontcache.cpp | 3 +-- src/fontcache.h | 7 ------- src/fontcache/freetypefontcache.cpp | 1 - src/os/macosx/font_osx.cpp | 1 - src/os/windows/font_win32.cpp | 1 - 5 files changed, 1 insertion(+), 12 deletions(-) diff --git a/src/fontcache.cpp b/src/fontcache.cpp index 1f01e9b327..80defbd24b 100644 --- a/src/fontcache.cpp +++ b/src/fontcache.cpp @@ -33,8 +33,7 @@ FontCacheSettings _fcsettings; * @param fs The size of the font. */ FontCache::FontCache(FontSize fs) : parent(FontCache::Get(fs)), fs(fs), height(_default_font_height[fs]), - ascender(_default_font_ascender[fs]), descender(_default_font_ascender[fs] - _default_font_height[fs]), - units_per_em(1) + ascender(_default_font_ascender[fs]), descender(_default_font_ascender[fs] - _default_font_height[fs]) { assert(this->parent == nullptr || this->fs == this->parent->fs); FontCache::caches[this->fs] = this; diff --git a/src/fontcache.h b/src/fontcache.h index fee0e26f3e..648fe4caa4 100644 --- a/src/fontcache.h +++ b/src/fontcache.h @@ -26,7 +26,6 @@ protected: int height; ///< The height of the font. int ascender; ///< The ascender value of the font. int descender; ///< The descender value of the font. - int units_per_em; ///< The units per EM value of the font. public: FontCache(FontSize fs); @@ -60,12 +59,6 @@ public: */ inline int GetDescender() const{ return this->descender; } - /** - * Get the units per EM value of the font. - * @return The units per EM value of the font. - */ - inline int GetUnitsPerEM() const { return this->units_per_em; } - /** * Get the nominal font size of the font. * @return The nominal font size. diff --git a/src/fontcache/freetypefontcache.cpp b/src/fontcache/freetypefontcache.cpp index 00d45a251a..72dae34111 100644 --- a/src/fontcache/freetypefontcache.cpp +++ b/src/fontcache/freetypefontcache.cpp @@ -105,7 +105,6 @@ void FreeTypeFontCache::SetFontSize(FontSize, FT_Face, int pixels) } if (err == FT_Err_Ok) { - this->units_per_em = this->face->units_per_EM; this->ascender = this->face->size->metrics.ascender >> 6; this->descender = this->face->size->metrics.descender >> 6; this->height = this->ascender - this->descender; diff --git a/src/os/macosx/font_osx.cpp b/src/os/macosx/font_osx.cpp index 6339f7f64e..7cb557fed3 100644 --- a/src/os/macosx/font_osx.cpp +++ b/src/os/macosx/font_osx.cpp @@ -166,7 +166,6 @@ void CoreTextFontCache::SetFontSize(int pixels) /* Query the font metrics we needed. We generally round all values up to * make sure we don't inadvertently cut off a row or column of pixels, * except when determining glyph to glyph advances. */ - this->units_per_em = CTFontGetUnitsPerEm(this->font.get()); this->ascender = (int)std::ceil(CTFontGetAscent(this->font.get())); this->descender = -(int)std::ceil(CTFontGetDescent(this->font.get())); this->height = this->ascender - this->descender; diff --git a/src/os/windows/font_win32.cpp b/src/os/windows/font_win32.cpp index a1293b3e47..767dfb83ab 100644 --- a/src/os/windows/font_win32.cpp +++ b/src/os/windows/font_win32.cpp @@ -168,7 +168,6 @@ void Win32FontCache::SetFontSize(int pixels) POUTLINETEXTMETRIC otm = (POUTLINETEXTMETRIC)new BYTE[otmSize]; GetOutlineTextMetrics(this->dc, otmSize, otm); - this->units_per_em = otm->otmEMSquare; this->ascender = otm->otmTextMetrics.tmAscent; this->descender = otm->otmTextMetrics.tmDescent; this->height = this->ascender + this->descender;