1. added encoding param to wxFontEncoding::EnumFamilies() which allows to get
the list of families supporting the given encoding 2. added encoding decoding logic to src/gtk/font.cpp so that now choosing an encoding different from default in GTK+ font selector dialog actually works git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4258 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -34,8 +34,9 @@
|
||||
// private functions
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// create the list of all fonts with the given spacing
|
||||
static char **CreateFontList(wxChar spacing, int *nFonts);
|
||||
// create the list of all fonts with the given spacing and encoding
|
||||
static char **CreateFontList(wxChar spacing, wxFontEncoding encoding,
|
||||
int *nFonts);
|
||||
|
||||
// extract all font families from the given font list and call our
|
||||
// OnFontFamily() for each of them
|
||||
@@ -56,10 +57,16 @@ static bool ProcessFamiliesFromFontList(wxFontEnumerator *This,
|
||||
// helpers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
static char **CreateFontList(wxChar spacing, int *nFonts)
|
||||
static char **CreateFontList(wxChar spacing,
|
||||
wxFontEncoding encoding,
|
||||
int *nFonts)
|
||||
{
|
||||
wxString xencoding, xregistry;
|
||||
wxGetXFontEncoding(encoding, &xencoding, &xregistry);
|
||||
|
||||
wxString pattern;
|
||||
pattern.Printf(wxT("-*-*-*-*-*-*-*-*-*-*-%c-*-*-*"), spacing);
|
||||
pattern.Printf(wxT("-*-*-*-*-*-*-*-*-*-*-%c-*-%s-%s"),
|
||||
spacing, xregistry.c_str(), xencoding.c_str());
|
||||
|
||||
// get the list of all fonts
|
||||
return XListFonts((Display *)wxGetDisplay(), pattern.mb_str(), 32767, nFonts);
|
||||
@@ -106,7 +113,8 @@ static bool ProcessFamiliesFromFontList(wxFontEnumerator *This,
|
||||
// wxFontEnumerator
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
bool wxFontEnumerator::EnumerateFamilies(bool fixedWidthOnly)
|
||||
bool wxFontEnumerator::EnumerateFamilies(wxFontEncoding encoding,
|
||||
bool fixedWidthOnly)
|
||||
{
|
||||
int nFonts;
|
||||
char **fonts;
|
||||
@@ -114,7 +122,7 @@ bool wxFontEnumerator::EnumerateFamilies(bool fixedWidthOnly)
|
||||
if ( fixedWidthOnly )
|
||||
{
|
||||
bool cont = TRUE;
|
||||
fonts = CreateFontList(wxT('m'), &nFonts);
|
||||
fonts = CreateFontList(wxT('m'), encoding, &nFonts);
|
||||
if ( fonts )
|
||||
{
|
||||
cont = ProcessFamiliesFromFontList(this, fonts, nFonts);
|
||||
@@ -127,7 +135,7 @@ bool wxFontEnumerator::EnumerateFamilies(bool fixedWidthOnly)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
fonts = CreateFontList(wxT('c'), &nFonts);
|
||||
fonts = CreateFontList(wxT('c'), encoding, &nFonts);
|
||||
if ( !fonts )
|
||||
{
|
||||
return TRUE;
|
||||
@@ -135,11 +143,14 @@ bool wxFontEnumerator::EnumerateFamilies(bool fixedWidthOnly)
|
||||
}
|
||||
else
|
||||
{
|
||||
fonts = CreateFontList(wxT('*'), &nFonts);
|
||||
fonts = CreateFontList(wxT('*'), encoding, &nFonts);
|
||||
|
||||
if ( !fonts )
|
||||
{
|
||||
wxFAIL_MSG(wxT("No fonts at all on this system?"));
|
||||
// it's ok if there are no fonts in given encoding - but it's not
|
||||
// ok if there are no fonts at all
|
||||
wxASSERT_MSG(encoding != wxFONTENCODING_SYSTEM,
|
||||
wxT("No fonts at all on this system?"));
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
@@ -780,6 +780,34 @@ static wxNativeFont wxLoadQueryFont(int pointSize,
|
||||
}
|
||||
|
||||
wxString xregistry, xencoding;
|
||||
if ( !wxGetXFontEncoding(encoding, &xregistry, &xencoding) )
|
||||
{
|
||||
fontSpec.Printf(wxT("-*-*-*-*-*-*-*-*-*-*-*-*-%s-%s"),
|
||||
xregistry.c_str(), xencoding.c_str());
|
||||
if ( !wxTestFontSpec(fontSpec) )
|
||||
{
|
||||
// this encoding isn't available - what to do?
|
||||
xregistry =
|
||||
xencoding = wxT("*");
|
||||
}
|
||||
}
|
||||
|
||||
// construct the X font spec from our data
|
||||
fontSpec.Printf(wxT("-*-%s-%s-%s-normal-*-*-%d-*-*-*-*-%s-%s"),
|
||||
xfamily.c_str(), xweight.c_str(), xstyle.c_str(),
|
||||
pointSize, xregistry.c_str(), xencoding.c_str());
|
||||
|
||||
return wxLoadFont(fontSpec);
|
||||
}
|
||||
|
||||
bool wxGetXFontEncoding(wxFontEncoding encoding,
|
||||
wxString *pregistry, wxString *pencoding)
|
||||
{
|
||||
wxCHECK_MSG( pencoding && pregistry, FALSE, wxT("bad pointer") );
|
||||
|
||||
wxString& xencoding = *pencoding;
|
||||
wxString& xregistry = *pregistry;
|
||||
|
||||
if ( encoding == wxFONTENCODING_DEFAULT )
|
||||
{
|
||||
// use the apps default
|
||||
@@ -830,6 +858,7 @@ static wxNativeFont wxLoadQueryFont(int pointSize,
|
||||
case wxFONTENCODING_CP1252:
|
||||
{
|
||||
int cp = encoding - wxFONTENCODING_CP1250 + 1250;
|
||||
wxString fontSpec;
|
||||
fontSpec.Printf(wxT("-*-*-*-*-*-*-*-*-*-*-*-*-microsoft-cp%d"),
|
||||
cp);
|
||||
if ( wxTestFontSpec(fontSpec) )
|
||||
@@ -856,24 +885,7 @@ static wxNativeFont wxLoadQueryFont(int pointSize,
|
||||
xencoding = wxT("*");
|
||||
}
|
||||
|
||||
if ( test )
|
||||
{
|
||||
fontSpec.Printf(wxT("-*-*-*-*-*-*-*-*-*-*-*-*-%s-%s"),
|
||||
xregistry.c_str(), xencoding.c_str());
|
||||
if ( !wxTestFontSpec(fontSpec) )
|
||||
{
|
||||
// this encoding isn't available - what to do?
|
||||
xregistry =
|
||||
xencoding = wxT("*");
|
||||
}
|
||||
}
|
||||
|
||||
// construct the X font spec from our data
|
||||
fontSpec.Printf(wxT("-*-%s-%s-%s-normal-*-*-%d-*-*-*-*-%s-%s"),
|
||||
xfamily.c_str(), xweight.c_str(), xstyle.c_str(),
|
||||
pointSize, xregistry.c_str(), xencoding.c_str());
|
||||
|
||||
return wxLoadFont(fontSpec);
|
||||
return !test;
|
||||
}
|
||||
|
||||
wxNativeFont wxLoadQueryNearestFont(int pointSize,
|
||||
|
Reference in New Issue
Block a user