- wxFont *font = wxFont::New(fontInfo);
- if ( fontInfo != font->GetNativeFontInfoDesc() )
- wxLogError(wxT("wxNativeFontInfo ToString()/FromString() broken!"));
- else
- wxLogMessage(wxT("wxNativeFontInfo works: %s"), fontInfo.c_str());
+ wxASSERT_MSG(!font.Ok(), wxT("The font should now be invalid"));
+ wxMessageBox(wxT("Error trying to create a font with such description..."));
+ }
+}
+
+void MyFrame::OnSetEncoding(wxCommandEvent& WXUNUSED(event))
+{
+ wxFontEncoding enc = GetEncodingFromUser();
+ if ( enc == wxFONTENCODING_SYSTEM )
+ return;
+
+ wxFont font = m_canvas->GetTextFont();
+ font.SetEncoding(enc);
+ DoChangeFont(font);
+}
+
+wxFontEncoding MyFrame::GetEncodingFromUser()
+{
+ wxArrayString names;
+ wxArrayInt encodings;
+
+ const size_t count = wxFontMapper::GetSupportedEncodingsCount();
+ names.reserve(count);
+ encodings.reserve(count);
+
+ for ( size_t n = 0; n < count; n++ )
+ {
+ wxFontEncoding enc = wxFontMapper::GetEncoding(n);
+ encodings.push_back(enc);
+ names.push_back(wxFontMapper::GetEncodingName(enc));
+ }
+
+ int i = wxGetSingleChoiceIndex
+ (
+ wxT("Choose the encoding"),
+ SAMPLE_TITLE,
+ names,
+ this
+ );