Problems with wxX11 unicode fonts
Gerd Alber
gerd-alber at web.de
Tue Feb 27 05:51:49 PST 2007
> -----Ursprüngliche Nachricht-----
> Von: "Gerd Alber" <gerd-alber at web.de>
> Gesendet: 23.02.07 09:53:31
> An: wx-dev at lists.wxwidgets.org
> Betreff: Problems with wxX11 unicode fonts
> Hi All,
>
> I have problems to load fonts with a special facename. wxWidgets-2.8.0 is
> compiled with unicode and debug support with the wxX11 port. The version
> of pango is 1.10.0-3.
> First I use an xrc-file to load a frame with two wxStaticText with different fonts.
> When I start the application, always the standard font is loading. Without xrc-file,
> only with font.SetNativeFontInfo(wxT(“facename 10”)); a special fonts can be load.
> This shows only one effect with wxStaticText and wxTextCtrl. When I use the
> dc.DrawText()-method, the text always represents with the standard font.
> Without unicode-support (ansi), there are no problems.
> Knowledge someone why?
>
> Regard Gerd
>When I use the dc.DrawText()-method, the text always represents with the standard font
The Problem is in src/x11/dcclient.cpp at Line 1776 (wxWindowsDC::SetFont).
The return command must be deleted
> I have problems to load fonts with a special facename. wxWidgets-2.8.0 is
> compiled with unicode and debug support with the wxX11 port. The version
> of pango is 1.10.0-3.
I have written little code in src/x11/font.cpp to solve this Problem. The change
praying rift only the function Init() of the class wxFontRefData and only
the #if wxUSE_UNICODE part.
// Create native font info
// m_nativeFontInfo.description = pango_font_description_new();
//And set its values
// switch (m_family)
// {
// case wxFONTFAMILY_TELETYPE:
// pango_font_description_set_family( m_nativeFontInfo.description, "monospace" );
// break;
// case wxFONTFAMILY_ROMAN:
// pango_font_description_set_family( m_nativeFontInfo.description, "serif" );
// break;
// default:
// pango_font_description_set_family( m_nativeFontInfo.description, "sans" );
// break;
// }
if (m_nativeFontInfo.description)
pango_font_description_free( m_nativeFontInfo.description );
//Create native font info
m_nativeFontInfo.description = pango_font_description_new();
// Fontdescription with special facename
if(!faceName.empty()) {
m_nativeFontInfo.SetFaceName( faceName );
// When pango can't find the font with the facename, then the standard font are loaded
// m_faceName must set
if (!wxFontEnumerator::IsValidFacename(m_faceName)) {
m_nativeFontInfo.SetFaceName(wxT("Sans"));
m_faceName = wxT("Sans");
#if WXDEBUG
printf("Font facename not font. Set default font\n");
#endif
}
// there is a bug in at least pango <= 1.13 which makes it (or its backends)
// segfault for very big point sizes and for negative point sizes.
// To workaround that bug for pango <= 1.13
// (see http://bugzilla.gnome.org/show_bug.cgi?id=340229)
// we do the check on the size here using same (arbitrary) limits used by
// pango > 1.13. Note that the segfault could happen also for pointsize
// smaller than this limit !!
if(m_pointSize > 2 && m_pointSize < 90)
m_nativeFontInfo.SetPointSize( m_pointSize );
#if WXDEBUG
else
printf("Font point size negativ or to big\n");
#endif
m_nativeFontInfo.SetWeight( (wxFontWeight)m_weight );
m_nativeFontInfo.SetStyle( (wxFontStyle)m_style );
}
else { // When no facename
switch (m_family)
{
case wxFONTFAMILY_TELETYPE:
pango_font_description_set_family( m_nativeFontInfo.description, "monospace" );
break;
case wxFONTFAMILY_ROMAN:
pango_font_description_set_family( m_nativeFontInfo.description, "serif" );
break;
default:
pango_font_description_set_family( m_nativeFontInfo.description, "sans" );
break;
}
}
#endif
After this change, a font can be load with the given facename.
It will be nice, if the changes could be transferred in possibly form
into the wxWidgets project.
Sorry, for my bad English
Regard, Gerd
_______________________________________________________________________
Viren-Scan für Ihren PC! Jetzt für jeden. Sofort, online und kostenlos.
Gleich testen! http://www.pc-sicherheit.web.de/freescan/?mc=022222
More information about the wx-dev
mailing list