diff --git a/src/console_cmds.cpp b/src/console_cmds.cpp index 5fa8f2d5b8..c56b927181 100644 --- a/src/console_cmds.cpp +++ b/src/console_cmds.cpp @@ -2284,7 +2284,7 @@ DEF_CONSOLE_CMD(ConFont) InitFontCache(fs == FS_MONO); fc = FontCache::Get(fs); } - IConsolePrintF(CC_DEFAULT, "%s: \"%s\" %d %s [\"%s\" %d %s]", FontSizeToName(fs), fc->GetFontName(), fc->GetFontSize(), GetFontAAState(fs) ? "aa" : "noaa", setting->font.c_str(), setting->size, setting->aa ? "aa" : "noaa"); + IConsolePrintF(CC_DEFAULT, "%s: \"%s\" %d %s [\"%s\" %d %s]", FontSizeToName(fs), fc->GetFontName().c_str(), fc->GetFontSize(), GetFontAAState(fs) ? "aa" : "noaa", setting->font.c_str(), setting->size, setting->aa ? "aa" : "noaa"); } return true; diff --git a/src/crashlog.cpp b/src/crashlog.cpp index 401e0c6c29..827afb8dce 100644 --- a/src/crashlog.cpp +++ b/src/crashlog.cpp @@ -273,7 +273,7 @@ char *CrashLog::LogConfiguration(char *buffer, const char *last) const auto log_font = [&](FontSize fs) -> const char * { FontCache *fc = FontCache::Get(fs); if (fc != nullptr) { - return fc->GetFontName(); + return fc->GetFontName().c_str(); } else { return "[NULL]"; } diff --git a/src/fontcache.h b/src/fontcache.h index a84eec5012..2204c1aea0 100644 --- a/src/fontcache.h +++ b/src/fontcache.h @@ -138,7 +138,7 @@ public: * Get the name of this font. * @return The name of the font. */ - virtual const char *GetFontName() = 0; + virtual std::string GetFontName() = 0; /** * Get the font cache of a given font size. diff --git a/src/fontcache/freetypefontcache.cpp b/src/fontcache/freetypefontcache.cpp index 9f3c7f4e68..d568949bd5 100644 --- a/src/fontcache/freetypefontcache.cpp +++ b/src/fontcache/freetypefontcache.cpp @@ -15,6 +15,7 @@ #include "../core/math_func.hpp" #include "../zoom_func.h" #include "../fileio_func.h" +#include "../string_func.h" #include "truetypefontcache.h" #include "../table/control_codes.h" @@ -41,7 +42,7 @@ public: ~FreeTypeFontCache(); void ClearFontCache() override; GlyphID MapCharToGlyph(WChar key) override; - const char *GetFontName() override { return face->family_name; } + std::string GetFontName() override { return stdstr_fmt("%s, %s", face->family_name, face->style_name); } bool IsBuiltInFont() override { return false; } const void *GetOSHandle() override { return &face; } }; diff --git a/src/fontcache/spritefontcache.h b/src/fontcache/spritefontcache.h index a47b4ac18f..ce74972b3e 100644 --- a/src/fontcache/spritefontcache.h +++ b/src/fontcache/spritefontcache.h @@ -31,7 +31,7 @@ public: virtual bool GetDrawGlyphShadow(); virtual GlyphID MapCharToGlyph(WChar key) { assert(IsPrintable(key)); return SPRITE_GLYPH | key; } virtual const void *GetFontTable(uint32 tag, size_t &length) { length = 0; return nullptr; } - virtual const char *GetFontName() { return "sprite"; } + virtual std::string GetFontName() { return "sprite"; } virtual bool IsBuiltInFont() { return true; } }; diff --git a/src/os/macosx/font_osx.h b/src/os/macosx/font_osx.h index 7b58bc772c..72518c5676 100644 --- a/src/os/macosx/font_osx.h +++ b/src/os/macosx/font_osx.h @@ -30,7 +30,7 @@ public: void ClearFontCache() override; GlyphID MapCharToGlyph(WChar key) override; - const char *GetFontName() override { return font_name.c_str(); } + std::string GetFontName() override { return font_name; } bool IsBuiltInFont() override { return false; } const void *GetOSHandle() override { return font.get(); } }; diff --git a/src/os/macosx/string_osx.cpp b/src/os/macosx/string_osx.cpp index 68a683b876..25e8fb71c7 100644 --- a/src/os/macosx/string_osx.cpp +++ b/src/os/macosx/string_osx.cpp @@ -180,7 +180,7 @@ static CTRunDelegateCallbacks _sprite_font_callback = { if (font == nullptr) { if (!_font_cache[i.second->fc->GetSize()]) { /* Cache font information. */ - CFAutoRelease font_name(CFStringCreateWithCString(kCFAllocatorDefault, i.second->fc->GetFontName(), kCFStringEncodingUTF8)); + CFAutoRelease font_name(CFStringCreateWithCString(kCFAllocatorDefault, i.second->fc->GetFontName().c_str(), kCFStringEncodingUTF8)); _font_cache[i.second->fc->GetSize()].reset(CTFontCreateWithName(font_name.get(), i.second->fc->GetFontSize(), nullptr)); } font = _font_cache[i.second->fc->GetSize()].get(); diff --git a/src/os/windows/font_win32.h b/src/os/windows/font_win32.h index b83b2c5f35..7f5f62a7f2 100644 --- a/src/os/windows/font_win32.h +++ b/src/os/windows/font_win32.h @@ -34,7 +34,7 @@ public: ~Win32FontCache(); void ClearFontCache() override; GlyphID MapCharToGlyph(WChar key) override; - const char *GetFontName() override { return this->fontname.c_str(); } + std::string GetFontName() override { return this->fontname; } const void *GetOSHandle() override { return &this->logfont; } };