// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
+// for compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
// ============================================================================
// declarations
// ============================================================================
#pragma message enable nosimpint
#endif
-#include "wx/defs.h"
-#include "wx/string.h"
#include "wx/font.h"
-#include "wx/gdicmn.h"
-#include "wx/utils.h" // for wxGetDisplay()
+
+#ifndef WX_PRECOMP
+ #include "wx/string.h"
+ #include "wx/utils.h" // for wxGetDisplay()
+ #include "wx/settings.h"
+ #include "wx/gdicmn.h"
+#endif
+
#include "wx/fontutil.h" // for wxNativeFontInfo
#include "wx/tokenzr.h"
-#include "wx/settings.h"
#include "wx/x11/private.h"
{
public:
wxXFont();
- ~wxXFont();
+ virtual ~wxXFont();
WXFontStructPtr m_fontStruct; // XFontStruct
WXDisplay* m_display; // XDisplay
int family = wxDEFAULT,
int style = wxDEFAULT,
int weight = wxDEFAULT,
- bool underlined = FALSE,
+ bool underlined = false,
const wxString& faceName = wxEmptyString,
wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
void SetStyle(int style);
void SetWeight(int weight);
void SetUnderlined(bool underlined);
- void SetFaceName(const wxString& facename);
+ bool SetFaceName(const wxString& facename);
void SetEncoding(wxFontEncoding encoding);
- void SetNoAntiAliasing( bool no = TRUE ) { m_noAA = no; }
+ void SetNoAntiAliasing( bool no = true ) { m_noAA = no; }
bool GetNoAntiAliasing() const { return m_noAA; }
// and this one also modifies all the other font data fields
void wxFontRefData::InitFromNative()
{
- m_noAA = FALSE;
+ m_noAA = false;
#if wxUSE_UNICODE
// Get native info
break;
}
+// Not defined in some Pango versions
+#define wxPANGO_WEIGHT_SEMIBOLD 600
+
switch (pango_font_description_get_weight( desc ))
{
case PANGO_WEIGHT_ULTRALIGHT:
- m_weight = wxFONTWEIGHT_LIGHT;
- break;
case PANGO_WEIGHT_LIGHT:
m_weight = wxFONTWEIGHT_LIGHT;
break;
+
+ default:
+ wxFAIL_MSG(_T("unknown Pango font weight"));
+ // fall through
+
case PANGO_WEIGHT_NORMAL:
m_weight = wxFONTWEIGHT_NORMAL;
break;
+
+ case wxPANGO_WEIGHT_SEMIBOLD:
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;
}
// Pango description are never underlined (?)
- m_underlined = FALSE;
+ m_underlined = false;
// Cannot we choose that
m_encoding = wxFONTENCODING_SYSTEM;
}
// X fonts are never underlined...
- m_underlined = FALSE;
+ m_underlined = false;
// deal with font encoding
wxString
// the XLFD doesn't have "underlined" field anyhow
}
-void wxFontRefData::SetFaceName(const wxString& facename)
+bool wxFontRefData::SetFaceName(const wxString& facename)
{
m_faceName = facename;
+ return true;
}
void wxFontRefData::SetEncoding(wxFontEncoding encoding)
// wxFont
// ----------------------------------------------------------------------------
-void wxFont::Init()
-{
-}
-
wxFont::wxFont(const wxNativeFontInfo& info)
{
- Init();
-
#if wxUSE_UNICODE
Create( info.GetPointSize(),
info.GetFamily(),
m_refData = new wxFontRefData(pointSize, family, style, weight,
underlined, faceName, encoding);
- return TRUE;
+ return true;
}
#if !wxUSE_UNICODE
if( !fontname )
{
*this = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT);
- return TRUE;
+ return true;
}
m_refData = new wxFontRefData();
}
//else: unknown encoding - may be give a warning here?
else
- return FALSE;
+ return false;
}
- return TRUE;
+ return true;
}
#endif // !wxUSE_UNICODE
wxString wxFont::GetFaceName() const
{
- wxCHECK_MSG( Ok(), wxT(""), wxT("invalid font") );
+ wxCHECK_MSG( Ok(), wxEmptyString, wxT("invalid font") );
return M_FONTDATA->m_faceName;
}
bool wxFont::GetUnderlined() const
{
- wxCHECK_MSG( Ok(), FALSE, wxT("invalid font") );
+ wxCHECK_MSG( Ok(), false, wxT("invalid font") );
return M_FONTDATA->m_underlined;
}
bool wxFont::IsFixedWidth() const
{
- wxCHECK_MSG( Ok(), FALSE, wxT("invalid font") );
+ wxCHECK_MSG( Ok(), false, wxT("invalid font") );
#if wxUSE_UNICODE
return wxFontBase::IsFixedWidth();
#else
// Robert, is this right? HasNativeFont doesn't exist.
- if ( TRUE )
+ if ( true )
// if ( M_FONTDATA->HasNativeFont() )
{
// the monospace fonts are supposed to have "M" in the spacing field
M_FONTDATA->SetWeight(weight);
}
-void wxFont::SetFaceName(const wxString& faceName)
+bool wxFont::SetFaceName(const wxString& faceName)
{
Unshare();
- M_FONTDATA->SetFaceName(faceName);
+ return M_FONTDATA->SetFaceName(faceName) &&
+ wxFontBase::SetFaceName(faceName);
}
void wxFont::SetUnderlined(bool underlined)
if (xFontName == "-*-*-*-*-*--*-*-*-*-*-*-*-*")
// wxFont constructor not called with native font info parameter => take M_FONTDATA values
xFontName.Clear();
-
+
// not found, create a new one
XFontStruct *font = (XFontStruct *)
wxLoadQueryNearestFont(pointSize,