// headers
// ----------------------------------------------------------------------------
-#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
- #pragma implementation "font.h"
-#endif
-
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
// Pango sometimes needs to have a size
int pango_size = pango_font_description_get_size( desc );
if (pango_size == 0)
- pango_font_description_set_size( desc, 12 * PANGO_SCALE);
+ m_nativeFontInfo.SetPointSize(12);
- m_pointSize = pango_font_description_get_size( desc ) / PANGO_SCALE;
-
- switch (pango_font_description_get_style( desc ))
- {
- case PANGO_STYLE_NORMAL:
- m_style = wxFONTSTYLE_NORMAL;
- break;
- case PANGO_STYLE_ITALIC:
- m_style = wxFONTSTYLE_ITALIC;
- break;
- case PANGO_STYLE_OBLIQUE:
- m_style = wxFONTSTYLE_SLANT;
- break;
- }
-
- PangoWeight pango_weight = pango_font_description_get_weight( desc );
-
- if (pango_weight >= 600)
- {
- m_weight = wxFONTWEIGHT_BOLD;
- }
- else if (pango_weight < 350)
- {
- m_weight = wxFONTWEIGHT_LIGHT;
- }
- else
- {
- m_weight = wxFONTWEIGHT_NORMAL;
- }
+ m_pointSize = m_nativeFontInfo.GetPointSize();
+ m_style = m_nativeFontInfo.GetStyle();
+ m_weight = m_nativeFontInfo.GetWeight();
if (m_faceName == wxT("monospace"))
{
m_pointSize = pointSize;
#ifdef __WXGTK20__
- // Get native info
- PangoFontDescription *desc = m_nativeFontInfo.description;
-
- pango_font_description_set_size( desc, m_pointSize * PANGO_SCALE );
+ m_nativeFontInfo.SetPointSize(pointSize);
#else
if ( HasNativeFont() )
{
m_style = style;
#ifdef __WXGTK20__
- // Get native info
- PangoFontDescription *desc = m_nativeFontInfo.description;
-
- switch ( style )
- {
- case wxFONTSTYLE_ITALIC:
- pango_font_description_set_style( desc, PANGO_STYLE_ITALIC );
- break;
- case wxFONTSTYLE_SLANT:
- pango_font_description_set_style( desc, PANGO_STYLE_OBLIQUE );
- break;
- default:
- wxFAIL_MSG( _T("unknown font style") );
- // fall through
- case wxFONTSTYLE_NORMAL:
- pango_font_description_set_style( desc, PANGO_STYLE_NORMAL );
- break;
- }
+ m_nativeFontInfo.SetStyle((wxFontStyle)style);
#else
if ( HasNativeFont() )
{
m_weight = weight;
#ifdef __WXGTK20__
- PangoFontDescription *desc = m_nativeFontInfo.description;
- switch ( weight )
- {
- case wxFONTWEIGHT_BOLD:
- pango_font_description_set_weight(desc, PANGO_WEIGHT_BOLD);
- break;
-
- case wxFONTWEIGHT_LIGHT:
- pango_font_description_set_weight(desc, PANGO_WEIGHT_LIGHT);
- break;
-
- default:
- wxFAIL_MSG( _T("unknown font weight") );
- // fall through
-
- case wxFONTWEIGHT_NORMAL:
- // unspecified
- pango_font_description_set_weight(desc, PANGO_WEIGHT_NORMAL);
- }
+ m_nativeFontInfo.SetWeight((wxFontWeight)weight);
#else //!__WXGTK20__
if ( HasNativeFont() )
{
{
m_faceName = facename;
-#ifndef __WXGTK20__
+#ifdef __WXGTK20__
+ m_nativeFontInfo.SetFaceName(facename);
+#else
if ( HasNativeFont() )
{
m_nativeFontInfo.SetXFontComponent(wxXLFD_FAMILY, facename);
wxCHECK_MSG( Ok(), 0, wxT("invalid font") );
#if wxUSE_PANGO
- return M_FONTDATA->HasNativeFont() ? M_FONTDATA->m_nativeFontInfo.GetFamily()
- : M_FONTDATA->m_family;
+ int ret = M_FONTDATA->m_family;
+ if (M_FONTDATA->HasNativeFont())
+ // wxNativeFontInfo::GetFamily is expensive, must not call more than once
+ ret = M_FONTDATA->m_nativeFontInfo.GetFamily();
+
+ if (ret == wxFONTFAMILY_DEFAULT)
+ ret = M_FONTDATA->m_family;
+
+ return ret;
#else
return M_FONTDATA->m_family;
#endif
{
wxCHECK_MSG( Ok(), FALSE, wxT("invalid font") );
-#if wxUSE_PANGO
- return M_FONTDATA->HasNativeFont() ? M_FONTDATA->m_nativeFontInfo.GetUnderlined()
- : M_FONTDATA->m_underlined;
-#else
return M_FONTDATA->m_underlined;
-#endif
}
wxFontEncoding wxFont::GetEncoding() const