1 /////////////////////////////////////////////////////////////////////////////
2 // Name: common/fontmap.cpp
3 // Purpose: wxFontMapper class
4 // Author: Vadim Zeitlin
8 // Copyright: (c) Vadim Zeitlin
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
21 #pragma implementation "fontmap.h"
24 // For compilers that support precompilation, includes "wx.h".
25 #include "wx/wxprec.h"
39 #include "wx/module.h"
40 #include "wx/fontmap.h"
43 #include "wx/config.h"
44 #include "wx/memconf.h"
48 #include "wx/fontutil.h"
49 #include "wx/msgdlg.h"
50 #include "wx/fontdlg.h"
51 #include "wx/choicdlg.h"
54 #include "wx/encconv.h"
56 // ----------------------------------------------------------------------------
58 // ----------------------------------------------------------------------------
60 // the config paths we use
62 static const wxChar
* FONTMAPPER_ROOT_PATH
= wxT("/wxWindows/FontMapper");
63 static const wxChar
* FONTMAPPER_CHARSET_PATH
= wxT("Charsets");
64 static const wxChar
* FONTMAPPER_CHARSET_ALIAS_PATH
= wxT("Aliases");
66 // we only ask questions in GUI mode
68 static const wxChar
* FONTMAPPER_FONT_FROM_ENCODING_PATH
= wxT("Encodings");
69 static const wxChar
* FONTMAPPER_FONT_DONT_ASK
= wxT("none");
71 #endif // wxUSE_CONFIG
73 // encodings supported by GetEncodingDescription
74 static wxFontEncoding gs_encodings
[] =
76 wxFONTENCODING_ISO8859_1
,
77 wxFONTENCODING_ISO8859_2
,
78 wxFONTENCODING_ISO8859_3
,
79 wxFONTENCODING_ISO8859_4
,
80 wxFONTENCODING_ISO8859_5
,
81 wxFONTENCODING_ISO8859_6
,
82 wxFONTENCODING_ISO8859_7
,
83 wxFONTENCODING_ISO8859_8
,
84 wxFONTENCODING_ISO8859_9
,
85 wxFONTENCODING_ISO8859_10
,
86 wxFONTENCODING_ISO8859_11
,
87 wxFONTENCODING_ISO8859_12
,
88 wxFONTENCODING_ISO8859_13
,
89 wxFONTENCODING_ISO8859_14
,
90 wxFONTENCODING_ISO8859_15
,
96 wxFONTENCODING_CP1250
,
97 wxFONTENCODING_CP1251
,
98 wxFONTENCODING_CP1252
,
99 wxFONTENCODING_CP1253
,
100 wxFONTENCODING_CP1254
,
101 wxFONTENCODING_CP1255
,
102 wxFONTENCODING_CP1256
,
103 wxFONTENCODING_CP1257
,
104 wxFONTENCODING_CP437
,
109 // the descriptions for them
110 static const wxChar
* gs_encodingDescs
[] =
112 wxTRANSLATE( "Western European (ISO-8859-1)" ),
113 wxTRANSLATE( "Central European (ISO-8859-2)" ),
114 wxTRANSLATE( "Esperanto (ISO-8859-3)" ),
115 wxTRANSLATE( "Baltic (old) (ISO-8859-4)" ),
116 wxTRANSLATE( "Cyrillic (ISO-8859-5)" ),
117 wxTRANSLATE( "Arabic (ISO-8859-6)" ),
118 wxTRANSLATE( "Greek (ISO-8859-7)" ),
119 wxTRANSLATE( "Hebrew (ISO-8859-8)" ),
120 wxTRANSLATE( "Turkish (ISO-8859-9)" ),
121 wxTRANSLATE( "Nordic (ISO-8859-10)" ),
122 wxTRANSLATE( "Thai (ISO-8859-11)" ),
123 wxTRANSLATE( "Indian (ISO-8859-12)" ),
124 wxTRANSLATE( "Baltic (ISO-8859-13)" ),
125 wxTRANSLATE( "Celtic (ISO-8859-14)" ),
126 wxTRANSLATE( "Western European with Euro (ISO-8859-15)" ),
127 wxTRANSLATE( "KOI8-R" ),
128 wxTRANSLATE( "Windows Japanese (CP 932)" ),
129 wxTRANSLATE( "Windows Chinese Simplified (CP 936)" ),
130 wxTRANSLATE( "Windows Korean (CP 949)" ),
131 wxTRANSLATE( "Windows Chinese Traditional (CP 950)" ),
132 wxTRANSLATE( "Windows Central European (CP 1250)" ),
133 wxTRANSLATE( "Windows Cyrillic (CP 1251)" ),
134 wxTRANSLATE( "Windows Western European (CP 1252)" ),
135 wxTRANSLATE( "Windows Greek (CP 1253)" ),
136 wxTRANSLATE( "Windows Turkish (CP 1254)" ),
137 wxTRANSLATE( "Windows Hebrew (CP 1255)" ),
138 wxTRANSLATE( "Windows Arabic (CP 1256)" ),
139 wxTRANSLATE( "Windows Baltic (CP 1257)" ),
140 wxTRANSLATE( "Windows/DOS OEM (CP 437)" ),
141 wxTRANSLATE( "Unicode 7 bit (UTF-7)" ),
142 wxTRANSLATE( "Unicode 8 bit (UTF-8)" ),
145 // and the internal names (these are not translated on purpose!)
146 static const wxChar
* gs_encodingNames
[] =
157 wxT( "iso-8859-10" ),
158 wxT( "iso-8859-11" ),
159 wxT( "iso-8859-12" ),
160 wxT( "iso-8859-13" ),
161 wxT( "iso-8859-14" ),
162 wxT( "iso-8859-15" ),
164 wxT( "windows-932" ),
165 wxT( "windows-936" ),
166 wxT( "windows-949" ),
167 wxT( "windows-950" ),
168 wxT( "windows-1250" ),
169 wxT( "windows-1251" ),
170 wxT( "windows-1252" ),
171 wxT( "windows-1253" ),
172 wxT( "windows-1254" ),
173 wxT( "windows-1255" ),
174 wxT( "windows-1256" ),
175 wxT( "windows-1257" ),
176 wxT( "windows-437" ),
182 // ----------------------------------------------------------------------------
184 // ----------------------------------------------------------------------------
186 // change the config path during the lifetime of this object
187 class wxFontMapperPathChanger
190 wxFontMapperPathChanger(wxFontMapper
*fontMapper
, const wxString
& path
)
192 m_fontMapper
= fontMapper
;
193 m_ok
= m_fontMapper
->ChangePath(path
, &m_pathOld
);
196 bool IsOk() const { return m_ok
; }
198 ~wxFontMapperPathChanger()
201 m_fontMapper
->RestorePath(m_pathOld
);
205 wxFontMapper
*m_fontMapper
;
210 // ============================================================================
212 // ============================================================================
214 // ----------------------------------------------------------------------------
216 // ----------------------------------------------------------------------------
218 wxFontMapper::wxFontMapper()
222 m_configIsDummy
= FALSE
;
223 #endif // wxUSE_CONFIG
226 m_windowParent
= NULL
;
230 wxFontMapper::~wxFontMapper()
233 if ( m_configIsDummy
)
235 #endif // wxUSE_CONFIG
238 wxFontMapper
*wxFontMapper::sm_instance
= NULL
;
240 /*static*/ wxFontMapper
*wxFontMapper::Get()
243 sm_instance
= new wxFontMapper
;
247 /*static*/ wxFontMapper
*wxFontMapper::Set(wxFontMapper
*mapper
)
249 wxFontMapper
*old
= sm_instance
;
250 sm_instance
= mapper
;
254 class wxFontMapperModule
: public wxModule
257 wxFontMapperModule() : wxModule() {}
258 virtual bool OnInit() { return TRUE
; }
259 virtual void OnExit() { delete wxFontMapper::Set(NULL
); }
261 DECLARE_DYNAMIC_CLASS(wxFontMapperModule
)
264 IMPLEMENT_DYNAMIC_CLASS(wxFontMapperModule
, wxModule
)
266 // ----------------------------------------------------------------------------
268 // ----------------------------------------------------------------------------
272 /* static */ const wxChar
*wxFontMapper::GetDefaultConfigPath()
274 return FONTMAPPER_ROOT_PATH
;
277 void wxFontMapper::SetConfigPath(const wxString
& prefix
)
279 wxCHECK_RET( !prefix
.IsEmpty() && prefix
[0] == wxCONFIG_PATH_SEPARATOR
,
280 wxT("an absolute path should be given to wxFontMapper::SetConfigPath()") );
282 m_configRootPath
= prefix
;
285 // ----------------------------------------------------------------------------
286 // get config object and path for it
287 // ----------------------------------------------------------------------------
289 wxConfigBase
*wxFontMapper::GetConfig()
294 m_config
= wxConfig::Get(FALSE
/*don't create on demand*/ );
298 // we still want to have a config object because otherwise we would
299 // keep asking the user the same questions in the interactive mode,
300 // so create a dummy config which won't write to any files/registry
301 // but will allow us to remember the results of the questions at
302 // least during this run
303 m_config
= new wxMemoryConfig
;
304 m_configIsDummy
= TRUE
;
305 // VS: we can't call wxConfig::Set(m_config) here because that would
306 // disable automatic wxConfig instance creation if this code was
307 // called before wxApp::OnInit (this happens in wxGTK -- it sets
308 // default wxFont encoding in wxApp::Initialize())
312 if ( m_configIsDummy
&& wxConfig::Get(FALSE
) != NULL
)
314 // VS: in case we created dummy m_config (see above), we want to switch back
315 // to the real one as soon as one becomes available.
317 m_config
= wxConfig::Get(FALSE
);
318 m_configIsDummy
= FALSE
;
319 // FIXME: ideally, we should add keys from dummy config to the real one now,
320 // but it is a low-priority task because typical wxWin application
321 // either doesn't use wxConfig at all or creates wxConfig object in
322 // wxApp::OnInit(), before any real interaction with the user takes
329 const wxString
& wxFontMapper::GetConfigPath()
331 if ( !m_configRootPath
)
334 m_configRootPath
= GetDefaultConfigPath();
337 return m_configRootPath
;
341 bool wxFontMapper::ChangePath(const wxString
& pathNew
, wxString
*pathOld
)
344 wxConfigBase
*config
= GetConfig();
348 *pathOld
= config
->GetPath();
350 wxString path
= GetConfigPath();
351 if ( path
.IsEmpty() || path
.Last() != wxCONFIG_PATH_SEPARATOR
)
353 path
+= wxCONFIG_PATH_SEPARATOR
;
356 wxASSERT_MSG( !pathNew
|| (pathNew
[0] != wxCONFIG_PATH_SEPARATOR
),
357 wxT("should be a relative path") );
361 config
->SetPath(path
);
369 void wxFontMapper::RestorePath(const wxString
& pathOld
)
372 GetConfig()->SetPath(pathOld
);
377 // ----------------------------------------------------------------------------
378 // charset/encoding correspondence
379 // ----------------------------------------------------------------------------
382 wxString
wxFontMapper::GetEncodingDescription(wxFontEncoding encoding
)
384 if ( encoding
== wxFONTENCODING_DEFAULT
)
386 return _("Default encoding");
389 size_t count
= WXSIZEOF(gs_encodingDescs
);
391 wxASSERT_MSG( count
== WXSIZEOF(gs_encodings
),
392 wxT("inconsitency detected - forgot to update one of the arrays?") );
394 for ( size_t i
= 0; i
< count
; i
++ )
396 if ( gs_encodings
[i
] == encoding
)
398 return wxGetTranslation(gs_encodingDescs
[i
]);
403 str
.Printf(_("Unknown encoding (%d)"), encoding
);
409 wxString
wxFontMapper::GetEncodingName(wxFontEncoding encoding
)
411 if ( encoding
== wxFONTENCODING_DEFAULT
)
416 size_t count
= WXSIZEOF(gs_encodingNames
);
418 wxASSERT_MSG( count
== WXSIZEOF(gs_encodings
),
419 wxT("inconsistency detected - forgot to update one of the arrays?") );
421 for ( size_t i
= 0; i
< count
; i
++ )
423 if ( gs_encodings
[i
] == encoding
)
425 return gs_encodingNames
[i
];
430 str
.Printf(_("unknown-%d"), encoding
);
435 wxFontEncoding
wxFontMapper::CharsetToEncoding(const wxString
& charset
,
438 // a special pseudo encoding which means "don't ask me about this charset
439 // any more" - we need it to avoid driving the user crazy with asking him
440 // time after time about the same charset which he [presumably] doesn't
441 // have the fonts fot
442 static const int wxFONTENCODING_UNKNOWN
= -2;
444 wxFontEncoding encoding
= wxFONTENCODING_SYSTEM
;
446 // we're going to modify it, make a copy
447 wxString cs
= charset
;
450 // first try the user-defined settings
452 if ( ChangePath(FONTMAPPER_CHARSET_PATH
, &pathOld
) )
454 wxConfigBase
*config
= GetConfig();
456 // do we have an encoding for this charset?
457 long value
= config
->Read(charset
, -1l);
460 if ( value
== wxFONTENCODING_UNKNOWN
)
462 // don't try to find it, in particular don't ask the user
463 return wxFONTENCODING_SYSTEM
;
466 if ( value
>= 0 && value
<= wxFONTENCODING_MAX
)
468 encoding
= (wxFontEncoding
)value
;
472 wxLogDebug(wxT("corrupted config data: invalid encoding %ld for charset '%s' ignored"),
473 value
, charset
.c_str());
477 if ( encoding
== wxFONTENCODING_SYSTEM
)
479 // may be we have an alias?
480 config
->SetPath(FONTMAPPER_CHARSET_ALIAS_PATH
);
482 wxString alias
= config
->Read(charset
);
485 // yes, we do - use it instead
490 RestorePath(pathOld
);
492 #endif // wxUSE_CONFIG
494 // if didn't find it there, try to recognize it ourselves
495 if ( encoding
== wxFONTENCODING_SYSTEM
)
501 // discard the optional quotes
504 if ( cs
[0u] == _T('"') && cs
.Last() == _T('"') )
506 cs
= wxString(cs
.c_str(), cs
.length() - 1);
512 if ( cs
.empty() || cs
== _T("US-ASCII") )
514 encoding
= wxFONTENCODING_DEFAULT
;
516 else if ( cs
== wxT("UTF-7") )
518 encoding
= wxFONTENCODING_UTF7
;
520 else if ( cs
== wxT("UTF-8") )
522 encoding
= wxFONTENCODING_UTF8
;
524 else if ( cs
== wxT("KOI8-R") ||
525 cs
== wxT("KOI8-U") ||
526 cs
== wxT("KOI8-RU") )
528 // although koi8-ru is not strictly speaking the same as koi8-r,
529 // they are similar enough to make mapping it to koi8 better than
530 // not reckognizing it at all
531 encoding
= wxFONTENCODING_KOI8
;
533 else if ( cs
.Left(3) == wxT("ISO") )
535 // the dash is optional (or, to be exact, it is not, but
536 // several brokenmails "forget" it)
537 const wxChar
*p
= cs
.c_str() + 3;
538 if ( *p
== wxT('-') )
542 if ( wxSscanf(p
, wxT("8859-%u"), &value
) == 1 )
544 // make it 0 based and check that it is strictly positive in
545 // the process (no such thing as iso8859-0 encoding)
546 if ( (value
-- > 0) &&
547 (value
< wxFONTENCODING_ISO8859_MAX
-
548 wxFONTENCODING_ISO8859_1
) )
550 // it's a valid ISO8859 encoding
551 value
+= wxFONTENCODING_ISO8859_1
;
552 encoding
= (wxFontEncoding
)value
;
556 else // check for Windows charsets
559 if ( cs
.Left(7) == wxT("WINDOWS") )
563 else if ( cs
.Left(2) == wxT("CP") )
567 else // not a Windows encoding
574 const wxChar
*p
= cs
.c_str() + len
;
575 if ( *p
== wxT('-') )
579 if ( wxSscanf(p
, wxT("%u"), &value
) == 1 )
584 if ( value
< wxFONTENCODING_CP12_MAX
-
585 wxFONTENCODING_CP1250
)
587 // a valid Windows code page
588 value
+= wxFONTENCODING_CP1250
;
589 encoding
= (wxFontEncoding
)value
;
596 encoding
= wxFONTENCODING_CP932
;
600 encoding
= wxFONTENCODING_CP936
;
604 encoding
= wxFONTENCODING_CP949
;
608 encoding
= wxFONTENCODING_CP950
;
618 // if still no luck, ask the user - unless disabled
619 if ( (encoding
== wxFONTENCODING_SYSTEM
) && interactive
)
621 // prepare the dialog data
624 wxString
title(m_titleDialog
);
626 title
<< wxTheApp
->GetAppName() << _(": unknown charset");
630 msg
.Printf(_("The charset '%s' is unknown. You may select\nanother charset to replace it with or choose\n[Cancel] if it cannot be replaced"), charset
.c_str());
632 // the list of choices
633 size_t count
= WXSIZEOF(gs_encodingDescs
);
635 wxASSERT_MSG( count
== WXSIZEOF(gs_encodings
),
636 wxT("inconsitency detected - forgot to update one of the arrays?") );
638 wxString
*encodingNamesTranslated
= new wxString
[count
];
640 for ( size_t i
= 0; i
< count
; i
++ )
642 encodingNamesTranslated
[i
] = wxGetTranslation(gs_encodingDescs
[i
]);
646 wxWindow
*parent
= m_windowParent
;
648 parent
= wxTheApp
->GetTopWindow();
650 // do ask the user and get back the index in encodings table
651 int n
= wxGetSingleChoiceIndex(msg
, title
,
653 encodingNamesTranslated
,
656 delete [] encodingNamesTranslated
;
660 encoding
= gs_encodings
[n
];
664 // save the result in the config now
665 if ( ChangePath(FONTMAPPER_CHARSET_PATH
, &pathOld
) )
667 wxConfigBase
*config
= GetConfig();
669 // remember the alt encoding for this charset - or remember that
671 long value
= n
== -1 ? wxFONTENCODING_UNKNOWN
: (long)encoding
;
672 if ( !config
->Write(charset
, value
) )
674 wxLogError(_("Failed to remember the encoding for the charset '%s'."), charset
.c_str());
677 RestorePath(pathOld
);
679 #endif // wxUSE_CONFIG
686 // ----------------------------------------------------------------------------
687 // support for unknown encodings: we maintain a map between the
688 // (platform-specific) strings identifying them and our wxFontEncodings they
689 // correspond to which is used by GetFontForEncoding() function
690 // ----------------------------------------------------------------------------
694 bool wxFontMapper::TestAltEncoding(const wxString
& configEntry
,
695 wxFontEncoding encReplacement
,
696 wxNativeEncodingInfo
*info
)
698 if ( wxGetNativeFontEncoding(encReplacement
, info
) &&
699 wxTestFontEncoding(*info
) )
702 // remember the mapping in the config
703 wxFontMapperPathChanger
path(this, FONTMAPPER_FONT_FROM_ENCODING_PATH
);
707 GetConfig()->Write(configEntry
, info
->ToString());
709 #endif // wxUSE_CONFIG
717 class ReentrancyBlocker
720 ReentrancyBlocker(bool& b
) : m_b(b
) { m_b
= TRUE
; }
721 ~ReentrancyBlocker() { m_b
= FALSE
; }
728 bool wxFontMapper::GetAltForEncoding(wxFontEncoding encoding
,
729 wxNativeEncodingInfo
*info
,
730 const wxString
& facename
,
734 // we need a flag to prevent infinite recursion which happens, for
735 // example, when GetAltForEncoding() is called from an OnPaint() handler:
736 // in this case, wxYield() which is called from wxMessageBox() we use here
737 // will lead to another call of OnPaint() and hence to another call of
738 // GetAltForEncoding() - and it is impossible to catch this from the user
739 // code because we are called from wxFont ctor implicitly.
741 // assume we're always called from the main thread, so that it is safe to
743 static bool s_inGetAltForEncoding
= FALSE
;
745 if ( interactive
&& s_inGetAltForEncoding
)
748 ReentrancyBlocker
blocker(s_inGetAltForEncoding
);
751 wxCHECK_MSG( info
, FALSE
, wxT("bad pointer in GetAltForEncoding") );
753 info
->facename
= facename
;
755 if ( encoding
== wxFONTENCODING_DEFAULT
)
757 encoding
= wxFont::GetDefaultEncoding();
760 // if we failed to load the system default encoding, something is really
761 // wrong and we'd better stop now - otherwise we will go into endless
762 // recursion trying to create the font in the msg box with the error
764 if ( encoding
== wxFONTENCODING_SYSTEM
)
766 wxLogFatalError(_("can't load any font, aborting"));
768 // wxLogFatalError doesn't return
771 wxString configEntry
,
772 encName
= GetEncodingName(encoding
);
775 configEntry
= facename
+ _T("_");
777 configEntry
+= encName
;
780 // do we have a font spec for this encoding?
782 if ( ChangePath(FONTMAPPER_FONT_FROM_ENCODING_PATH
, &pathOld
) )
784 wxConfigBase
*config
= GetConfig();
786 wxString fontinfo
= config
->Read(configEntry
);
788 RestorePath(pathOld
);
790 // this special value means that we don't know of fonts for this
791 // encoding but, moreover, have already asked the user as well and he
792 // didn't specify any font neither
793 if ( fontinfo
== FONTMAPPER_FONT_DONT_ASK
)
797 else // use the info entered the last time
799 if ( !!fontinfo
&& !!facename
)
801 // we tried to find a match with facename - now try without it
802 fontinfo
= config
->Read(encName
);
807 if ( info
->FromString(fontinfo
) )
809 if ( wxTestFontEncoding(*info
) )
814 //else: no such fonts, look for something else
815 // (should we erase the outdated value?)
819 wxLogDebug(wxT("corrupted config data: string '%s' is not a valid font encoding info"),
823 //else: there is no information in config about this encoding
826 #endif // wxUSE_CONFIG
828 // now try to map this encoding to a compatible one which we have on this
830 wxFontEncodingArray equiv
= wxEncodingConverter::GetAllEquivalents(encoding
);
831 size_t count
= equiv
.GetCount();
832 bool foundEquivEncoding
= FALSE
;
833 wxFontEncoding equivEncoding
= wxFONTENCODING_SYSTEM
;
836 for ( size_t i
= 0; i
< count
&& !foundEquivEncoding
; i
++ )
838 // don't test for encoding itself, we already know we don't have it
839 if ( equiv
[i
] == encoding
)
842 if ( TestAltEncoding(configEntry
, equiv
[i
], info
) )
844 equivEncoding
= equiv
[i
];
846 foundEquivEncoding
= TRUE
;
855 wxString
title(m_titleDialog
);
857 title
<< wxTheApp
->GetAppName() << _(": unknown encoding");
860 wxString encDesc
= GetEncodingDescription(encoding
),
862 if ( foundEquivEncoding
)
864 // ask the user if he wants to override found alternative encoding
865 msg
.Printf(_("No font for displaying text in encoding '%s' found,\nbut an alternative encoding '%s' is available.\nDo you want to use this encoding (otherwise you will have to choose another one)?"),
866 encDesc
.c_str(), GetEncodingDescription(equivEncoding
).c_str());
870 msg
.Printf(_("No font for displaying text in encoding '%s' found.\nWould you like to select a font to be used for this encoding\n(otherwise the text in this encoding will not be shown correctly)?"),
874 // the question is different in 2 cases so the answer has to be
875 // interpreted differently as well
876 int answer
= foundEquivEncoding
? wxNO
: wxYES
;
878 if ( wxMessageBox(msg
, title
,
879 wxICON_QUESTION
| wxYES_NO
,
880 m_windowParent
) == answer
)
883 data
.SetEncoding(encoding
);
884 data
.EncodingInfo() = *info
;
885 wxFontDialog
dialog(m_windowParent
, &data
);
886 if ( dialog
.ShowModal() == wxID_OK
)
888 wxFontData retData
= dialog
.GetFontData();
889 wxFont font
= retData
.GetChosenFont();
891 *info
= retData
.EncodingInfo();
892 info
->encoding
= retData
.GetEncoding();
895 // remember this in the config
896 if ( ChangePath(FONTMAPPER_FONT_FROM_ENCODING_PATH
, &pathOld
) )
898 GetConfig()->Write(configEntry
, info
->ToString());
900 RestorePath(pathOld
);
902 #endif // wxUSE_CONFIG
906 //else: the user canceled the font selection dialog
910 // the user doesn't want to select a font for this encoding
911 // or selected to use equivalent encoding
913 // remember it to avoid asking the same question again later
915 if ( ChangePath(FONTMAPPER_FONT_FROM_ENCODING_PATH
, &pathOld
) )
920 foundEquivEncoding
? info
->ToString().c_str()
921 : FONTMAPPER_FONT_DONT_ASK
924 RestorePath(pathOld
);
926 #endif // wxUSE_CONFIG
929 //else: we're in non-interactive mode
930 #endif // wxUSE_FONTDLG
932 return foundEquivEncoding
;
935 bool wxFontMapper::GetAltForEncoding(wxFontEncoding encoding
,
936 wxFontEncoding
*alt_encoding
,
937 const wxString
& facename
,
940 wxNativeEncodingInfo info
;
941 bool r
= GetAltForEncoding(encoding
, &info
, facename
, interactive
);
942 *alt_encoding
= info
.encoding
;
946 bool wxFontMapper::IsEncodingAvailable(wxFontEncoding encoding
,
947 const wxString
& facename
)
949 wxNativeEncodingInfo info
;
951 if (wxGetNativeFontEncoding(encoding
, &info
))
953 info
.facename
= facename
;
954 return wxTestFontEncoding(info
);
962 #endif // wxUSE_FONTMAP