X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/ab29bb87b20df9b6afb50d13044506e143e84951..fc32630a5e03e60a67d4ef53fc59985ea087b451:/src/common/fontcmn.cpp diff --git a/src/common/fontcmn.cpp b/src/common/fontcmn.cpp index 4fcd211e53..5ac8cce15e 100644 --- a/src/common/fontcmn.cpp +++ b/src/common/fontcmn.cpp @@ -341,11 +341,6 @@ bool wxFontBase::operator==(const wxFont& font) const ); } -bool wxFontBase::operator!=(const wxFont& font) const -{ - return !(*this == font); -} - wxString wxFontBase::GetFamilyString() const { wxCHECK_MSG( Ok(), wxT("wxDEFAULT"), wxT("invalid font") ); @@ -388,13 +383,17 @@ wxString wxFontBase::GetWeightString() const } } -bool wxFontBase::SetFaceName(const wxString &facename) +bool wxFontBase::SetFaceName(const wxString& facename) { +#if wxUSE_FONTENUM if (!wxFontEnumerator::IsValidFacename(facename)) { UnRef(); // make Ok() return false return false; } +#else // !wxUSE_FONTENUM + wxUnusedVar(facename); +#endif // wxUSE_FONTENUM/!wxUSE_FONTENUM return true; } @@ -405,8 +404,9 @@ bool wxFontBase::SetFaceName(const wxString &facename) // ---------------------------------------------------------------------------- // Up to now, there are no native implementations of this function: -void wxNativeFontInfo::SetFaceName(const wxArrayString &facenames) +void wxNativeFontInfo::SetFaceName(const wxArrayString& facenames) { +#if wxUSE_FONTENUM for (size_t i=0; i < facenames.GetCount(); i++) { if (wxFontEnumerator::IsValidFacename(facenames[i])) @@ -420,6 +420,9 @@ void wxNativeFontInfo::SetFaceName(const wxArrayString &facenames) wxString validfacename = wxFontEnumerator::GetFacenames().Item(0); wxLogTrace(wxT("font"), wxT("Falling back to '%s'"), validfacename.c_str()); SetFaceName(validfacename); +#else // !wxUSE_FONTENUM + SetFaceName(facenames[0]); +#endif // wxUSE_FONTENUM/!wxUSE_FONTENUM } @@ -744,9 +747,15 @@ bool wxNativeFontInfo::FromUserString(const wxString& s) // NB: the check on the facename is implemented in wxFontBase::SetFaceName // and not in wxNativeFontInfo::SetFaceName thus we need to explicitely // call here wxFontEnumerator::IsValidFacename - if (!wxFontEnumerator::IsValidFacename(face) || - !SetFaceName(face)) + if ( +#if wxUSE_FONTENUM + !wxFontEnumerator::IsValidFacename(face) || +#endif // wxUSE_FONTENUM + !SetFaceName(face) ) + { SetFaceName(wxNORMAL_FONT->GetFaceName()); + } + face.clear(); } } @@ -757,9 +766,14 @@ bool wxNativeFontInfo::FromUserString(const wxString& s) // NB: the check on the facename is implemented in wxFontBase::SetFaceName // and not in wxNativeFontInfo::SetFaceName thus we need to explicitely // call here wxFontEnumerator::IsValidFacename - if (!wxFontEnumerator::IsValidFacename(face) || - !SetFaceName(face)) - SetFaceName(wxNORMAL_FONT->GetFaceName()); + if ( +#if wxUSE_FONTENUM + !wxFontEnumerator::IsValidFacename(face) || +#endif // wxUSE_FONTENUM + !SetFaceName(face) ) + { + SetFaceName(wxNORMAL_FONT->GetFaceName()); + } } // set point size to default value if size was not given @@ -780,3 +794,26 @@ bool wxNativeFontInfo::FromUserString(const wxString& s) } #endif // generic or wxMSW or wxOS2 + + +// wxFont <-> wxString utilities, used by wxConfig +wxString wxToString(const wxFontBase& font) +{ + return font.IsOk() ? font.GetNativeFontInfoDesc() + : wxString(); +} + +bool wxFromString(const wxString& str, wxFontBase *font) +{ + wxCHECK_MSG( font, false, _T("NULL output parameter") ); + + if ( str.empty() ) + { + *font = wxNullFont; + return true; + } + + return font->SetNativeFontInfo(str); +} + +