+ m_textctrl->LoadFile(filename);
+
+ if ( fontenc == wxFONTENCODING_UTF8 ||
+ !wxFontMapper::Get()->IsEncodingAvailable(fontenc) )
+ {
+ // try to find some similar encoding:
+ wxFontEncoding encAlt;
+ if ( wxFontMapper::Get()->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());
+ }
+ }
+#endif // wxUSE_FILEDLG
+}
+
+void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
+{
+ wxMessageBox(wxT("wxWidgets font demo\n")
+ wxT("(c) 1999 Vadim Zeitlin"),
+ wxT("About Font"),
+ wxOK | wxICON_INFORMATION, this);