+ if ( fontenc == wxFONTENCODING_UTF8 ||
+ !wxTheFontMapper->IsEncodingAvailable(fontenc) )
+ {
+ // try to find some similar encoding:
+ wxFontEncoding encAlt;
+ if ( wxTheFontMapper->GetAltForEncoding(fontenc, &encAlt) )
+ {
+ wxEncodingConverter conv;
+
+ if (conv.Init(fontenc, encAlt))
+ {
+ fontenc = encAlt;
+ m_textctrl -> SetValue(conv.Convert(m_textctrl -> GetValue()));
+ }
+ else
+ {
+ wxLogWarning(wxT("Cannot convert from '%s' to '%s'."),
+ wxFontMapper::GetEncodingDescription(fontenc).c_str(),
+ wxFontMapper::GetEncodingDescription(encAlt).c_str());
+ }
+ }
+ else
+ wxLogWarning(wxT("No fonts for encoding '%s' on this system."),
+ wxFontMapper::GetEncodingDescription(fontenc).c_str());
+ }
+
+ // and now create the correct font
+ if ( !DoEnumerateFamilies(FALSE, fontenc, TRUE /* silent */) )
+ {
+ wxFont font(12, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL,
+ wxFONTWEIGHT_NORMAL, FALSE /* !underlined */,
+ wxEmptyString /* facename */, fontenc);
+ if ( font.Ok() )
+ {
+ DoChangeFont(font);
+ }
+ else
+ {
+ wxLogWarning(wxT("No fonts for encoding '%s' on this system."),
+ wxFontMapper::GetEncodingDescription(fontenc).c_str());
+ }
+ }