bool wxNativeFontInfo::SetFaceName(const wxString& facename) { pango_font_description_set_family(description, wxPANGO_CONV(facename)); // we return true because Pango doesn't tell us if the call failed or not; // instead on wxGTK wxFont::SetFaceName() will call wxFontBase::SetFaceName() // which does the check return true; }
bool wxNativeFontInfo::FromString(const wxString& s) { wxString str(s); // Pango font description doesn't have 'underlined' or 'strikethrough' // attributes, so we handle them specially by extracting them from the // string before passing it to Pango. m_underlined = str.StartsWith(wxS("underlined "), &str); m_strikethrough = str.StartsWith(wxS("strikethrough "), &str); if (description) pango_font_description_free( description ); // there is a bug in at least pango <= 1.13 which makes it (or its backends) // segfault for very big point sizes and for negative point sizes. // To workaround that bug for pango <= 1.13 // (see http://bugzilla.gnome.org/show_bug.cgi?id=340229) // we do the check on the size here using same (arbitrary) limits used by // pango > 1.13. Note that the segfault could happen also for pointsize // smaller than this limit !! const size_t pos = str.find_last_of(wxS(" ")); double size; if ( pos != wxString::npos && wxString(str, pos + 1).ToDouble(&size) ) { wxString sizeStr; if ( size < 1 ) sizeStr = wxS("1"); else if ( size >= 1E6 ) sizeStr = wxS("1E6"); if ( !sizeStr.empty() ) { // replace the old size with the adjusted one str = wxString(s, 0, pos) + sizeStr; } } description = pango_font_description_from_string(wxPANGO_CONV(str)); #if wxUSE_FONTENUM // ensure a valid facename is selected if (!wxFontEnumerator::IsValidFacename(GetFaceName())) SetFaceName(wxNORMAL_FONT->GetFaceName()); #endif // wxUSE_FONTENUM return true; }
bool wxNativeFontInfo::FromString(const wxString& s) { if (description) pango_font_description_free( description ); // there is a bug in at least pango <= 1.13 which makes it (or its backends) // segfault for very big point sizes and for negative point sizes. // To workaround that bug for pango <= 1.13 // (see http://bugzilla.gnome.org/show_bug.cgi?id=340229) // we do the check on the size here using same (arbitrary) limits used by // pango > 1.13. Note that the segfault could happen also for pointsize // smaller than this limit !! wxString str(s); const size_t pos = str.find_last_of(_T(" ")); double size; if ( pos != wxString::npos && wxString(str, pos + 1).ToDouble(&size) ) { wxString sizeStr; if ( size < 1 ) sizeStr = _T("1"); else if ( size >= 1E6 ) sizeStr = _T("1E6"); if ( !sizeStr.empty() ) { // replace the old size with the adjusted one str = wxString(s, 0, pos) + sizeStr; } } description = pango_font_description_from_string(wxPANGO_CONV(str)); // ensure a valid facename is selected if (!wxFontEnumerator::IsValidFacename(GetFaceName())) SetFaceName(wxNORMAL_FONT->GetFaceName()); return true; }
bool wxNativeFontInfo::SetFaceName(const wxString& facename) { pango_font_description_set_family(description, wxPANGO_CONV(facename)); return true; }