diff options
author | Michael Lutz <michi@icosahedron.de> | 2018-11-25 02:02:20 +0100 |
---|---|---|
committer | Owen Rudge <owen@owenrudge.net> | 2019-05-14 11:21:36 +0100 |
commit | d2ed4260772e0a2ce8805e9c40525d0abb9345ea (patch) | |
tree | 2daef56dc038e55aa630a4f55f8af0eeeaff9b06 /src/strings.cpp | |
parent | 2675762ae9c58c47dc442b422927206c7bee13a8 (diff) | |
download | openttd-d2ed4260772e0a2ce8805e9c40525d0abb9345ea.tar.xz |
Codechange: [Win32] Pass a native GDI font description around when we have one, instead of repeatedly guessing the font.
Diffstat (limited to 'src/strings.cpp')
-rw-r--r-- | src/strings.cpp | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/strings.cpp b/src/strings.cpp index fda92d8a7..5d186e717 100644 --- a/src/strings.cpp +++ b/src/strings.cpp @@ -2068,13 +2068,18 @@ class LanguagePackGlyphSearcher : public MissingGlyphSearcher { return false; } - void SetFontNames(FreeTypeSettings *settings, const char *font_name) override + void SetFontNames(FreeTypeSettings *settings, const char *font_name, const void *os_data) override { #if defined(WITH_FREETYPE) || defined(_WIN32) strecpy(settings->small.font, font_name, lastof(settings->small.font)); strecpy(settings->medium.font, font_name, lastof(settings->medium.font)); strecpy(settings->large.font, font_name, lastof(settings->large.font)); -#endif /* WITH_FREETYPE */ + + free(settings->medium.os_handle); // Only free one, they are all the same pointer. + settings->small.os_handle = os_data; + settings->medium.os_handle = os_data; + settings->large.os_handle = os_data; +#endif } }; @@ -2103,8 +2108,14 @@ void CheckForMissingGlyphs(bool base_font, MissingGlyphSearcher *searcher) FreeTypeSettings backup; memcpy(&backup, &_freetype, sizeof(backup)); + _freetype.mono.os_handle = nullptr; + _freetype.medium.os_handle = nullptr; + bad_font = !SetFallbackFont(&_freetype, _langpack->isocode, _langpack->winlangid, searcher); + free(_freetype.mono.os_handle); + free(_freetype.medium.os_handle); + memcpy(&_freetype, &backup, sizeof(backup)); if (bad_font && base_font) { |