Cache for wxLocale::IsAvailable().

This commit is contained in:
Jeff Young 2024-01-17 16:13:53 +00:00
parent 455fae45d8
commit 047b5f8b18
1 changed files with 12 additions and 3 deletions

View File

@ -371,6 +371,8 @@ void FONTCONFIG::ListFonts( std::vector<std::string>& aFonts, const std::string&
// GTK, on the other hand, doesn't appear to support wxLocale::IsAvailable(),
// so we can't run these checks.
static std::map<wxString, bool> availableLanguages;
FcStrSet* langStrSet = FcLangSetGetLangs( langSet );
FcStrList* langStrList = FcStrListCreate( langStrSet );
FcChar8* langStr = FcStrListNext( langStrList );
@ -384,9 +386,16 @@ void FONTCONFIG::ListFonts( std::vector<std::string>& aFonts, const std::string&
else while( langStr )
{
wxString langWxStr( reinterpret_cast<char *>( langStr ) );
const wxLanguageInfo* langInfo = wxLocale::FindLanguageInfo( langWxStr );
if( langInfo && wxLocale::IsAvailable( langInfo->Language ) )
if( availableLanguages.find( langWxStr ) == availableLanguages.end() )
{
const wxLanguageInfo* langInfo = wxLocale::FindLanguageInfo( langWxStr );
bool available = langInfo && wxLocale::IsAvailable( langInfo->Language );
availableLanguages[ langWxStr ] = available;
}
if( availableLanguages[ langWxStr ] )
{
langSupported = true;
break;