#endif
#ifndef WX_PRECOMP
+ #include "wx/font.h" // wxFont enums
#include "wx/encinfo.h"
#endif // PCH
description = NULL;
}
-wxNativeFontInfo::wxNativeFontInfo(const wxNativeFontInfo& info)
+void
+wxNativeFontInfo::Init(const wxNativeFontInfo& info)
{
if (info.description)
description = pango_font_description_copy(info.description);
else
- description = NULL;
+ description = NULL;
}
-wxNativeFontInfo::~wxNativeFontInfo()
+void wxNativeFontInfo::Free()
{
if (description)
pango_font_description_free(description);
wxFontWeight wxNativeFontInfo::GetWeight() const
{
- wxFontWeight m_weight = wxFONTWEIGHT_NORMAL;
+#if 0
+ // We seem to currently initialize only by string.
+ // In that case PANGO_FONT_MASK_WEIGHT is always set.
+ if (!(pango_font_description_get_set_fields(description) & PANGO_FONT_MASK_WEIGHT))
+ return wxFONTWEIGHT_NORMAL;
+#endif
- switch (pango_font_description_get_weight( description ))
- {
- case PANGO_WEIGHT_ULTRALIGHT:
- m_weight = wxFONTWEIGHT_LIGHT;
- break;
- case PANGO_WEIGHT_LIGHT:
- m_weight = wxFONTWEIGHT_LIGHT;
- break;
- case PANGO_WEIGHT_NORMAL:
- m_weight = wxFONTWEIGHT_NORMAL;
- break;
- case PANGO_WEIGHT_BOLD:
- m_weight = wxFONTWEIGHT_BOLD;
- break;
- case PANGO_WEIGHT_ULTRABOLD:
- m_weight = wxFONTWEIGHT_BOLD;
- break;
- case PANGO_WEIGHT_HEAVY:
- m_weight = wxFONTWEIGHT_BOLD;
- break;
- }
+ PangoWeight pango_weight = pango_font_description_get_weight( description );
+
+ // Until the API can be changed the following ranges of weight values are used:
+ // wxFONTWEIGHT_LIGHT: 100 .. 349 - range of 250
+ // wxFONTWEIGHT_NORMAL: 350 .. 599 - range of 250
+ // wxFONTWEIGHT_BOLD: 600 .. 900 - range of 301 (600 is "semibold" already)
- return m_weight;
+ if (pango_weight >= 600)
+ return wxFONTWEIGHT_BOLD;
+
+ if (pango_weight < 350)
+ return wxFONTWEIGHT_LIGHT;
+
+ return wxFONTWEIGHT_NORMAL;
}
bool wxNativeFontInfo::GetUnderlined() const
bool wxGetNativeFontEncoding(wxFontEncoding encoding,
wxNativeEncodingInfo *info)
{
- return FALSE;
+ // we *must* return true for default encoding as otherwise wxFontMapper
+ // considers that we can't load any font and aborts with wxLogFatalError!
+ if ( encoding == wxFONTENCODING_SYSTEM )
+ {
+ info->facename.clear();
+ info->encoding = wxFONTENCODING_SYSTEM;
+ }
+
+ // pretend that we support everything, it's better than to always return
+ // false as the old code did
+ return true;
}
#else // GTK+ 1.x
break;
case wxFONTENCODING_GB2312:
- info->xregistry = wxT("GB2312"); // or the otherway round?
+ info->xregistry = wxT("GB2312"); // or the otherway round?
info->xencoding = wxT("*");
break;