1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/mgl/font.cpp
3 // Author: Vaclav Slavik
5 // Copyright: (c) 2001-2002 SciTech Software, Inc. (www.scitechsoft.com)
6 // Licence: wxWindows licence
7 /////////////////////////////////////////////////////////////////////////////
9 // ============================================================================
11 // ============================================================================
13 // ----------------------------------------------------------------------------
15 // ----------------------------------------------------------------------------
17 // For compilers that support precompilation, includes "wx.h".
18 #include "wx/wxprec.h"
26 #include "wx/private/fontmgr.h"
28 // ============================================================================
30 // ============================================================================
32 typedef wxFontMgrFontRefData wxFontRefData
;
33 #define M_FONTDATA ((wxFontRefData*)m_refData)
35 // ----------------------------------------------------------------------------
37 // ----------------------------------------------------------------------------
39 bool wxFont::Create(const wxNativeFontInfo
& info
)
41 return Create(info
.pointSize
, info
.family
, info
.style
, info
.weight
,
42 info
.underlined
, info
.faceName
, info
.encoding
);
45 bool wxFont::Create(int pointSize
,
51 wxFontEncoding encoding
)
53 m_refData
= new wxFontRefData(pointSize
, family
, style
, weight
,
54 underlined
, face
, encoding
);
58 wxGDIRefData
*wxFont::CreateGDIRefData() const
60 return new wxFontRefData
;
63 wxGDIRefData
*wxFont::CloneGDIRefData(const wxGDIRefData
*data
) const
65 return new wxFontRefData(*(wxFontRefData
*)data
);
69 // ----------------------------------------------------------------------------
71 // ----------------------------------------------------------------------------
73 struct font_t
*wxFont::GetMGLfont_t(float scale
, bool antialiased
)
75 wxCHECK_MSG( IsOk(), NULL
, wxT("invalid font") );
77 // we don't support DC scaling yet, so use scale=1
78 wxFontInstance
*i
= M_FONTDATA
->GetFontInstance(1.0, antialiased
);
79 return i
? i
->GetMGLfont_t() : NULL
;
82 int wxFont::GetPointSize() const
84 wxCHECK_MSG( IsOk(), 0, wxT("invalid font") );
86 return M_FONTDATA
->GetPointSize();
89 wxString
wxFont::GetFaceName() const
91 wxCHECK_MSG( IsOk(), wxEmptyString
, wxT("invalid font") );
93 return M_FONTDATA
->GetFaceName();
96 wxFontFamily
wxFont::DoGetFamily() const
98 return M_FONTDATA
->GetFamily();
101 wxFontStyle
wxFont::GetStyle() const
103 wxCHECK_MSG( IsOk(), wxFONTSTYLE_MAX
, wxT("invalid font") );
105 return M_FONTDATA
->GetStyle();
108 wxFontWeight
wxFont::GetWeight() const
110 wxCHECK_MSG( IsOk(), wxFONTWEIGHT_MAX
, wxT("invalid font") );
112 return M_FONTDATA
->GetWeight();
115 bool wxFont::GetUnderlined() const
117 wxCHECK_MSG( IsOk(), false, wxT("invalid font") );
119 return M_FONTDATA
->GetUnderlined();
123 wxFontEncoding
wxFont::GetEncoding() const
125 wxCHECK_MSG( IsOk(), wxFONTENCODING_DEFAULT
, wxT("invalid font") );
127 return M_FONTDATA
->GetEncoding();
130 bool wxFont::IsFixedWidth() const
132 wxCHECK_MSG( IsOk(), false, wxT("invalid font") );
134 return M_FONTDATA
->IsFixedWidth();
137 const wxNativeFontInfo
*wxFont::GetNativeFontInfo() const
139 wxCHECK_MSG( IsOk(), NULL
, wxT("invalid font") );
141 return M_FONTDATA
->GetNativeFontInfo();
144 // ----------------------------------------------------------------------------
145 // change font attributes
146 // ----------------------------------------------------------------------------
148 void wxFont::SetPointSize(int pointSize
)
151 M_FONTDATA
->SetPointSize(pointSize
);
154 void wxFont::SetFamily(wxFontFamily family
)
157 M_FONTDATA
->SetFamily(family
);
160 void wxFont::SetStyle(wxFontStyle style
)
163 M_FONTDATA
->SetStyle(style
);
166 void wxFont::SetWeight(wxFontWeight weight
)
169 M_FONTDATA
->SetWeight(weight
);
172 bool wxFont::SetFaceName(const wxString
& faceName
)
175 M_FONTDATA
->SetFaceName(faceName
);
176 return wxFontBase::SetFaceName(faceName
);
179 void wxFont::SetUnderlined(bool underlined
)
182 M_FONTDATA
->SetUnderlined(underlined
);
185 void wxFont::SetEncoding(wxFontEncoding encoding
)
188 M_FONTDATA
->SetEncoding(encoding
);