+ wxASSERT_MSG(!font.IsOk(), wxT("The font should now be invalid"));
+ wxMessageBox(wxT("There is no font with such face name..."),
+ wxT("Invalid face name"), wxOK|wxICON_ERROR, this);
+ }
+}
+
+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
+ );
+
+ return i == -1 ? wxFONTENCODING_SYSTEM : (wxFontEncoding)encodings[i];
+}
+
+wxFontFamily MyFrame::GetFamilyFromUser()
+{
+ wxArrayString names;
+ wxArrayInt families;
+
+ families.push_back(wxFONTFAMILY_DECORATIVE);
+ families.push_back(wxFONTFAMILY_ROMAN);
+ families.push_back(wxFONTFAMILY_SCRIPT);
+ families.push_back(wxFONTFAMILY_SWISS);
+ families.push_back(wxFONTFAMILY_MODERN);
+ families.push_back(wxFONTFAMILY_TELETYPE);
+
+ names.push_back("DECORATIVE");
+ names.push_back("ROMAN");
+ names.push_back("SCRIPT");
+ names.push_back("SWISS");
+ names.push_back("MODERN");
+ names.push_back("TELETYPE");
+
+ int i = wxGetSingleChoiceIndex
+ (
+ wxT("Choose the family"),
+ SAMPLE_TITLE,
+ names,
+ this
+ );