#include "wx/fontutil.h" // for wxNativeFontInfo
#include "wx/tokenzr.h"
+#include "wx/fontenum.h"
#include "wx/x11/private.h"
#endif
};
+#define M_FONTDATA ((wxFontRefData*)m_refData)
+
// ----------------------------------------------------------------------------
// wxFontRefData
// ----------------------------------------------------------------------------
m_style = style == wxDEFAULT ? wxFONTSTYLE_NORMAL : style;
m_weight = weight == wxDEFAULT ? wxFONTWEIGHT_NORMAL : weight;
- // and here, do we really want to forbid creation of the font of the size
- // 90 (the value of wxDEFAULT)??
- m_pointSize = pointSize == wxDEFAULT || pointSize == -1
- ? wxDEFAULT_FONT_SIZE
- : pointSize;
-
m_underlined = underlined;
m_encoding = encoding;
#if wxUSE_UNICODE
+ if ( m_nativeFontInfo.description )
+ pango_font_description_free(m_nativeFontInfo.description);
+
// Create native font info
m_nativeFontInfo.description = pango_font_description_new();
- // And set its values
- switch (m_family)
+ // if a face name is specified, use it if it's available, otherwise use
+ // just the family
+ if ( faceName.empty() || !wxFontEnumerator::IsValidFacename(faceName) )
{
- case wxFONTFAMILY_MODERN:
- 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;
+ // TODO: scan system for valid fonts matching the given family instead
+ // of hardcoding them here
+ switch ( m_family )
+ {
+ case wxFONTFAMILY_TELETYPE:
+ m_faceName = wxT("monospace");
+ break;
+
+ case wxFONTFAMILY_ROMAN:
+ m_faceName = wxT("serif");
+ break;
+
+ default:
+ m_faceName = wxT("sans");
+ }
}
- SetStyle( m_style );
- SetPointSize( m_pointSize );
- SetWeight( m_weight );
-#endif
+ else // specified face name is available, use it
+ {
+ m_faceName = faceName;
+ }
+
+ m_nativeFontInfo.SetFaceName(m_faceName);
+ m_nativeFontInfo.SetWeight((wxFontWeight)m_weight);
+ m_nativeFontInfo.SetStyle((wxFontStyle)m_style);
+#endif // wxUSE_UNICODE
+
+ SetPointSize(pointSize);
}
void wxFontRefData::InitFromNative()
void wxFontRefData::SetPointSize(int pointSize)
{
- m_pointSize = pointSize;
+ // NB: Pango doesn't support point sizes less than 1
+ m_pointSize = pointSize == wxDEFAULT || pointSize < 1 ? wxDEFAULT_FONT_SIZE
+ : pointSize;
#if wxUSE_UNICODE
- // Get native info
- PangoFontDescription *desc = m_nativeFontInfo.description;
-
- pango_font_description_set_size( desc, m_pointSize * PANGO_SCALE );
+ m_nativeFontInfo.SetPointSize(m_pointSize);
#endif
}