From 6648cd46dcfa615e084e0960e677e5ecd39778a5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?V=C3=A1clav=20Slav=C3=ADk?= Date: Sat, 8 Jan 2000 23:45:31 +0000 Subject: [PATCH] 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 --- include/wx/fontmap.h | 13 +++++++++++++ src/common/fontmap.cpp | 28 ++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) 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); +} -- 2.45.2