From: Václav Slavík Date: Sat, 8 Jan 2000 23:45:31 +0000 (+0000) Subject: added IsEncodingAvailable and GetAltForEncoding extended by facename argument and... X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/6648cd46dcfa615e084e0960e677e5ecd39778a5 added IsEncodingAvailable and GetAltForEncoding extended by facename argument and added GetAltForEncoding alternative that returns only wxFontEncoding (and thus more useful for wxWin users) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@5313 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/include/wx/fontmap.h b/include/wx/fontmap.h index e5dc01d6e0..ba5403b81d 100644 --- a/include/wx/fontmap.h +++ b/include/wx/fontmap.h @@ -55,8 +55,21 @@ public: // return FALSE virtual bool GetAltForEncoding(wxFontEncoding encoding, wxNativeEncodingInfo *info, + const wxString& facename = wxEmptyString, bool interactive = TRUE); + // version better suitable for 'public' use. Returns wxFontEcoding + // that can be used it wxFont ctor + bool GetAltForEncoding(wxFontEncoding encoding, + wxFontEncoding *alt_encoding, + const wxString& facename = wxEmptyString, + bool interactive = TRUE); + + // checks whether given encoding is available in given face or not. + // If no facename is given, + virtual bool IsEncodingAvailable(wxFontEncoding encoding, + const wxString& facename = wxEmptyString); + // returns the encoding for the given charset (in the form of RFC 2046) or // wxFONTENCODING_SYSTEM if couldn't decode it virtual wxFontEncoding CharsetToEncoding(const wxString& charset, diff --git a/src/common/fontmap.cpp b/src/common/fontmap.cpp index 05b1edd2ab..56f3461d2d 100644 --- a/src/common/fontmap.cpp +++ b/src/common/fontmap.cpp @@ -498,10 +498,13 @@ bool wxFontMapper::TestAltEncoding(const wxString& configEntry, bool wxFontMapper::GetAltForEncoding(wxFontEncoding encoding, wxNativeEncodingInfo *info, + const wxString& facename, bool interactive) { wxCHECK_MSG( info, FALSE, wxT("bad pointer in GetAltForEncoding") ); + info->facename = facename; + if ( encoding == wxFONTENCODING_DEFAULT ) { encoding = wxFont::GetDefaultEncoding(); @@ -609,3 +612,28 @@ bool wxFontMapper::GetAltForEncoding(wxFontEncoding encoding, return FALSE; } + + + +bool wxFontMapper::GetAltForEncoding(wxFontEncoding encoding, + wxFontEncoding *alt_encoding, + const wxString& facename, + bool interactive) +{ + wxNativeEncodingInfo info; + bool r = GetAltForEncoding(encoding, &info, facename, interactive); + *alt_encoding = info.encoding; + return r; +} + + + +bool wxFontMapper::IsEncodingAvailable(wxFontEncoding encoding, + const wxString& facename) +{ + wxNativeEncodingInfo info; + + wxGetNativeFontEncoding(encoding, &info); + info.facename = facename; + return wxTestFontEncoding(info); +}