summaryrefslogtreecommitdiff
path: root/src/fontcache.cpp
diff options
context:
space:
mode:
authorrubidium42 <rubidium@openttd.org>2021-04-28 17:10:15 +0200
committerrubidium42 <rubidium42@users.noreply.github.com>2021-05-13 23:13:17 +0200
commit77330d09fd8307261e94fe0eb0260f5ca5cc3898 (patch)
tree0a2d3efe86b4f0047b558bb668dc9ed17ac63d3f /src/fontcache.cpp
parent65cbde4b30f8fdf6d4cf1196f6a596a5550c9aee (diff)
downloadopenttd-77330d09fd8307261e94fe0eb0260f5ca5cc3898.tar.xz
Codechange: move font settings to std::string
Diffstat (limited to 'src/fontcache.cpp')
-rw-r--r--src/fontcache.cpp15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/fontcache.cpp b/src/fontcache.cpp
index 530dc7cf8..2535ac69f 100644
--- a/src/fontcache.cpp
+++ b/src/fontcache.cpp
@@ -490,7 +490,7 @@ static void LoadFreeTypeFont(FontSize fs)
case FS_MONO: settings = &_freetype.mono; break;
}
- if (StrEmpty(settings->font)) return;
+ if (settings->font.empty()) return;
if (_library == nullptr) {
if (FT_Init_FreeType(&_library) != FT_Err_Ok) {
@@ -501,19 +501,20 @@ static void LoadFreeTypeFont(FontSize fs)
DEBUG(freetype, 2, "Initialized");
}
+ const char *font_name = settings->font.c_str();
FT_Face face = nullptr;
/* If font is an absolute path to a ttf, try loading that first. */
- FT_Error error = FT_New_Face(_library, settings->font, 0, &face);
+ FT_Error error = FT_New_Face(_library, font_name, 0, &face);
#if defined(WITH_COCOA)
extern void MacOSRegisterExternalFont(const char *file_path);
- if (error == FT_Err_Ok) MacOSRegisterExternalFont(settings->font);
+ if (error == FT_Err_Ok) MacOSRegisterExternalFont(font_name);
#endif
if (error != FT_Err_Ok) {
/* Check if font is a relative filename in one of our search-paths. */
- std::string full_font = FioFindFullPath(BASE_DIR, settings->font);
+ std::string full_font = FioFindFullPath(BASE_DIR, font_name);
if (!full_font.empty()) {
error = FT_New_Face(_library, full_font.c_str(), 0, &face);
#if defined(WITH_COCOA)
@@ -523,10 +524,10 @@ static void LoadFreeTypeFont(FontSize fs)
}
/* Try loading based on font face name (OS-wide fonts). */
- if (error != FT_Err_Ok) error = GetFontByFaceName(settings->font, &face);
+ if (error != FT_Err_Ok) error = GetFontByFaceName(font_name, &face);
if (error == FT_Err_Ok) {
- DEBUG(freetype, 2, "Requested '%s', using '%s %s'", settings->font, face->family_name, face->style_name);
+ DEBUG(freetype, 2, "Requested '%s', using '%s %s'", font_name, face->family_name, face->style_name);
/* Attempt to select the unicode character map */
error = FT_Select_Charmap(face, ft_encoding_unicode);
@@ -556,7 +557,7 @@ static void LoadFreeTypeFont(FontSize fs)
FT_Done_Face(face);
static const char *SIZE_TO_NAME[] = { "medium", "small", "large", "mono" };
- ShowInfoF("Unable to use '%s' for %s font, FreeType reported error 0x%X, using sprite font instead", settings->font, SIZE_TO_NAME[fs], error);
+ ShowInfoF("Unable to use '%s' for %s font, FreeType reported error 0x%X, using sprite font instead", font_name, SIZE_TO_NAME[fs], error);
return;
found_face: