X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/82545b58f4de558abbe45379b3175a94dc6fc410..7dc3cc31af71522b8fc55b7f97bcba7f5ef9eac5:/src/common/fontmap.cpp diff --git a/src/common/fontmap.cpp b/src/common/fontmap.cpp index 05b1edd2ab..1c9f225748 100644 --- a/src/common/fontmap.cpp +++ b/src/common/fontmap.cpp @@ -47,7 +47,7 @@ // ---------------------------------------------------------------------------- // the config paths we use -static const wxChar* FONTMAPPER_ROOT_PATH = wxT("FontMapper"); +static const wxChar* FONTMAPPER_ROOT_PATH = wxT("wxWindows/FontMapper"); static const wxChar* FONTMAPPER_CHARSET_PATH = wxT("Charsets"); static const wxChar* FONTMAPPER_CHARSET_ALIAS_PATH = wxT("Aliases"); static const wxChar* FONTMAPPER_FONT_FROM_ENCODING_PATH = wxT("Encodings"); @@ -223,7 +223,7 @@ wxConfigBase *wxFontMapper::GetConfig() if ( !m_config ) { // try the default - m_config = wxConfig::Get(); + m_config = wxConfig::Get(FALSE/*don't create on demand*/); } return m_config; @@ -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(); @@ -518,7 +521,7 @@ bool wxFontMapper::GetAltForEncoding(wxFontEncoding encoding, // wxFatalError doesn't return } - wxString configEntry = GetEncodingName(encoding); + wxString configEntry = facename + _T("_") + GetEncodingName(encoding); // do we have a font spec for this encoding? wxString pathOld; @@ -582,6 +585,7 @@ bool wxFontMapper::GetAltForEncoding(wxFontEncoding encoding, wxFont font = retData.GetChosenFont(); *info = retData.EncodingInfo(); + info -> encoding = retData.GetEncoding(); // remember this in the config if ( ChangePath(FONTMAPPER_FONT_FROM_ENCODING_PATH, &pathOld) ) @@ -601,7 +605,6 @@ bool wxFontMapper::GetAltForEncoding(wxFontEncoding encoding, // now try the default mappings: - wxFontEncodingArray equiv = wxEncodingConverter::GetAllEquivalents(encoding); for ( unsigned i = (equiv[0] == encoding) ? 1 : 0; i < equiv.GetCount(); i++ ) if ( TestAltEncoding(configEntry, equiv[i], info) ) @@ -609,3 +612,32 @@ 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; + + if (wxGetNativeFontEncoding(encoding, &info)) + { + info.facename = facename; + return wxTestFontEncoding(info); + } + else + return FALSE; +}