Change: Rename some freetype things to fontcache.
The font cache supports more than just FreeType as a font provider, but still used freetype in some naming. This now uses more suitable terms.
This commit is contained in:
@@ -57,7 +57,7 @@ FT_Error GetFontByFaceName(const char *font_name, FT_Face *face)
|
||||
}
|
||||
|
||||
if (os_err == noErr) {
|
||||
Debug(freetype, 3, "Font path for {}: {}", font_name, file_path);
|
||||
Debug(fontcache, 3, "Font path for {}: {}", font_name, file_path);
|
||||
err = FT_New_Face(_library, (const char *)file_path, 0, face);
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ FT_Error GetFontByFaceName(const char *font_name, FT_Face *face)
|
||||
#endif /* WITH_FREETYPE */
|
||||
|
||||
|
||||
bool SetFallbackFont(FreeTypeSettings *settings, const char *language_isocode, int winlangid, MissingGlyphSearcher *callback)
|
||||
bool SetFallbackFont(FontCacheSettings *settings, const char *language_isocode, int winlangid, MissingGlyphSearcher *callback)
|
||||
{
|
||||
/* Determine fallback font using CoreText. This uses the language isocode
|
||||
* to find a suitable font. CoreText is available from 10.5 onwards. */
|
||||
@@ -134,7 +134,7 @@ bool SetFallbackFont(FreeTypeSettings *settings, const char *language_isocode, i
|
||||
/* Save result. */
|
||||
callback->SetFontNames(settings, name);
|
||||
if (!callback->FindMissingGlyphs()) {
|
||||
Debug(freetype, 2, "CT-Font for {}: {}", language_isocode, name);
|
||||
Debug(fontcache, 2, "CT-Font for {}: {}", language_isocode, name);
|
||||
result = true;
|
||||
break;
|
||||
}
|
||||
@@ -221,7 +221,7 @@ void CoreTextFontCache::SetFontSize(int pixels)
|
||||
CFStringGetCString(font_name.get(), name, lengthof(name), kCFStringEncodingUTF8);
|
||||
this->font_name = name;
|
||||
|
||||
Debug(freetype, 2, "Loaded font '{}' with size {}", this->font_name, pixels);
|
||||
Debug(fontcache, 2, "Loaded font '{}' with size {}", this->font_name, pixels);
|
||||
}
|
||||
|
||||
GlyphID CoreTextFontCache::MapCharToGlyph(WChar key)
|
||||
@@ -350,13 +350,13 @@ void LoadCoreTextFont(FontSize fs)
|
||||
{
|
||||
static const char *SIZE_TO_NAME[] = { "medium", "small", "large", "mono" };
|
||||
|
||||
FreeTypeSubSetting *settings = nullptr;
|
||||
FontCacheSubSetting *settings = nullptr;
|
||||
switch (fs) {
|
||||
default: NOT_REACHED();
|
||||
case FS_SMALL: settings = &_freetype.small; break;
|
||||
case FS_NORMAL: settings = &_freetype.medium; break;
|
||||
case FS_LARGE: settings = &_freetype.large; break;
|
||||
case FS_MONO: settings = &_freetype.mono; break;
|
||||
case FS_SMALL: settings = &_fcsettings.small; break;
|
||||
case FS_NORMAL: settings = &_fcsettings.medium; break;
|
||||
case FS_LARGE: settings = &_fcsettings.large; break;
|
||||
case FS_MONO: settings = &_fcsettings.mono; break;
|
||||
}
|
||||
|
||||
if (settings->font.empty()) return;
|
||||
|
@@ -94,7 +94,7 @@ FT_Error GetFontByFaceName(const char *font_name, FT_Face *face)
|
||||
#endif /* WITH_FREETYPE */
|
||||
|
||||
|
||||
bool SetFallbackFont(FreeTypeSettings *settings, const char *language_isocode, int winlangid, MissingGlyphSearcher *callback)
|
||||
bool SetFallbackFont(FontCacheSettings *settings, const char *language_isocode, int winlangid, MissingGlyphSearcher *callback)
|
||||
{
|
||||
if (!FcInit()) return false;
|
||||
|
||||
@@ -148,7 +148,7 @@ bool SetFallbackFont(FreeTypeSettings *settings, const char *language_isocode, i
|
||||
callback->SetFontNames(settings, (const char *)file);
|
||||
|
||||
bool missing = callback->FindMissingGlyphs();
|
||||
Debug(freetype, 1, "Font \"{}\" misses{} glyphs", file, missing ? "" : " no");
|
||||
Debug(fontcache, 1, "Font \"{}\" misses{} glyphs", file, missing ? "" : " no");
|
||||
|
||||
if (!missing) {
|
||||
best_weight = value;
|
||||
@@ -159,7 +159,7 @@ bool SetFallbackFont(FreeTypeSettings *settings, const char *language_isocode, i
|
||||
if (best_font != nullptr) {
|
||||
ret = true;
|
||||
callback->SetFontNames(settings, best_font);
|
||||
InitFreeType(callback->Monospace());
|
||||
InitFontCache(callback->Monospace());
|
||||
}
|
||||
|
||||
/* Clean up the list of filenames. */
|
||||
|
@@ -78,7 +78,7 @@ FT_Error GetFontByFaceName(const char *font_name, FT_Face *face)
|
||||
ret = RegOpenKeyEx(HKEY_LOCAL_MACHINE, FONT_DIR_NT, 0, KEY_READ, &hKey);
|
||||
|
||||
if (ret != ERROR_SUCCESS) {
|
||||
Debug(freetype, 0, "Cannot open registry key HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Fonts");
|
||||
Debug(fontcache, 0, "Cannot open registry key HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Fonts");
|
||||
return err;
|
||||
}
|
||||
|
||||
@@ -113,7 +113,7 @@ FT_Error GetFontByFaceName(const char *font_name, FT_Face *face)
|
||||
}
|
||||
|
||||
if (!SUCCEEDED(SHGetFolderPath(nullptr, CSIDL_FONTS, nullptr, SHGFP_TYPE_CURRENT, vbuffer))) {
|
||||
Debug(freetype, 0, "SHGetFolderPath cannot return fonts directory");
|
||||
Debug(fontcache, 0, "SHGetFolderPath cannot return fonts directory");
|
||||
goto folder_error;
|
||||
}
|
||||
|
||||
@@ -268,7 +268,7 @@ public:
|
||||
};
|
||||
|
||||
struct EFCParam {
|
||||
FreeTypeSettings *settings;
|
||||
FontCacheSettings *settings;
|
||||
LOCALESIGNATURE locale;
|
||||
MissingGlyphSearcher *callback;
|
||||
FontList fonts;
|
||||
@@ -334,17 +334,17 @@ static int CALLBACK EnumFontCallback(const ENUMLOGFONTEX *logfont, const NEWTEXT
|
||||
|
||||
info->callback->SetFontNames(info->settings, font_name, &logfont->elfLogFont);
|
||||
if (info->callback->FindMissingGlyphs()) return 1;
|
||||
Debug(freetype, 1, "Fallback font: {} ({})", font_name, english_name);
|
||||
Debug(fontcache, 1, "Fallback font: {} ({})", font_name, english_name);
|
||||
return 0; // stop enumerating
|
||||
}
|
||||
|
||||
bool SetFallbackFont(FreeTypeSettings *settings, const char *language_isocode, int winlangid, MissingGlyphSearcher *callback)
|
||||
bool SetFallbackFont(FontCacheSettings *settings, const char *language_isocode, int winlangid, MissingGlyphSearcher *callback)
|
||||
{
|
||||
Debug(freetype, 1, "Trying fallback fonts");
|
||||
Debug(fontcache, 1, "Trying fallback fonts");
|
||||
EFCParam langInfo;
|
||||
if (GetLocaleInfo(MAKELCID(winlangid, SORT_DEFAULT), LOCALE_FONTSIGNATURE, (LPTSTR)&langInfo.locale, sizeof(langInfo.locale) / sizeof(wchar_t)) == 0) {
|
||||
/* Invalid langid or some other mysterious error, can't determine fallback font. */
|
||||
Debug(freetype, 1, "Can't get locale info for fallback font (langid=0x{:x})", winlangid);
|
||||
Debug(fontcache, 1, "Can't get locale info for fallback font (langid=0x{:x})", winlangid);
|
||||
return false;
|
||||
}
|
||||
langInfo.settings = settings;
|
||||
@@ -439,7 +439,7 @@ void Win32FontCache::SetFontSize(FontSize fs, int pixels)
|
||||
this->glyph_size.cx = otm->otmTextMetrics.tmMaxCharWidth;
|
||||
this->glyph_size.cy = otm->otmTextMetrics.tmHeight;
|
||||
|
||||
Debug(freetype, 2, "Loaded font '{}' with size {}", FS2OTTD((LPWSTR)((BYTE *)otm + (ptrdiff_t)otm->otmpFullName)), pixels);
|
||||
Debug(fontcache, 2, "Loaded font '{}' with size {}", FS2OTTD((LPWSTR)((BYTE *)otm + (ptrdiff_t)otm->otmpFullName)), pixels);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -579,12 +579,12 @@ void LoadWin32Font(FontSize fs)
|
||||
{
|
||||
static const char *SIZE_TO_NAME[] = { "medium", "small", "large", "mono" };
|
||||
|
||||
FreeTypeSubSetting *settings = nullptr;
|
||||
FontCacheSubSetting *settings = nullptr;
|
||||
switch (fs) {
|
||||
case FS_SMALL: settings = &_freetype.small; break;
|
||||
case FS_NORMAL: settings = &_freetype.medium; break;
|
||||
case FS_LARGE: settings = &_freetype.large; break;
|
||||
case FS_MONO: settings = &_freetype.mono; break;
|
||||
case FS_SMALL: settings = &_fcsettings.small; break;
|
||||
case FS_NORMAL: settings = &_fcsettings.medium; break;
|
||||
case FS_LARGE: settings = &_fcsettings.large; break;
|
||||
case FS_MONO: settings = &_fcsettings.mono; break;
|
||||
default: NOT_REACHED();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user