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 IMPLEMENT_DYNAMIC_CLASS(wxFont
, wxGDIObject
)
41 bool wxFont::Create(const wxNativeFontInfo
& info
)
43 return Create(info
.pointSize
, info
.family
, info
.style
, info
.weight
,
44 info
.underlined
, info
.faceName
, info
.encoding
);
47 bool wxFont::Create(int pointSize
,
53 wxFontEncoding encoding
)
55 m_refData
= new wxFontRefData(pointSize
, family
, style
, weight
,
56 underlined
, face
, encoding
);
60 wxObjectRefData
*wxFont::CreateRefData() const
62 return new wxFontRefData
;
65 wxObjectRefData
*wxFont::CloneRefData(const wxObjectRefData
*data
) const
67 return new wxFontRefData(*(wxFontRefData
*)data
);
71 // ----------------------------------------------------------------------------
73 // ----------------------------------------------------------------------------
75 struct font_t
*wxFont::GetMGLfont_t(float scale
, bool antialiased
)
77 wxCHECK_MSG( Ok(), NULL
, wxT("invalid font") );
79 // we don't support DC scaling yet, so use scale=1
80 wxFontInstance
*i
= M_FONTDATA
->GetFontInstance(1.0, antialiased
);
81 return i
? i
->GetMGLfont_t() : NULL
;
84 int wxFont::GetPointSize() const
86 wxCHECK_MSG( Ok(), 0, wxT("invalid font") );
88 return M_FONTDATA
->GetPointSize();
91 wxString
wxFont::GetFaceName() const
93 wxCHECK_MSG( Ok(), wxEmptyString
, wxT("invalid font") );
95 return M_FONTDATA
->GetFaceName();
98 int wxFont::GetFamily() const
100 wxCHECK_MSG( Ok(), 0, wxT("invalid font") );
102 return M_FONTDATA
->GetFamily();
105 int wxFont::GetStyle() const
107 wxCHECK_MSG( Ok(), 0, wxT("invalid font") );
109 return M_FONTDATA
->GetStyle();
112 int wxFont::GetWeight() const
114 wxCHECK_MSG( Ok(), 0, wxT("invalid font") );
116 return M_FONTDATA
->GetWeight();
119 bool wxFont::GetUnderlined() const
121 wxCHECK_MSG( Ok(), false, wxT("invalid font") );
123 return M_FONTDATA
->GetUnderlined();
127 wxFontEncoding
wxFont::GetEncoding() const
129 wxCHECK_MSG( Ok(), wxFONTENCODING_DEFAULT
, wxT("invalid font") );
131 return M_FONTDATA
->GetEncoding();
134 bool wxFont::IsFixedWidth() const
136 wxCHECK_MSG( Ok(), false, wxT("invalid font") );
138 return M_FONTDATA
->IsFixedWidth();
141 const wxNativeFontInfo
*wxFont::GetNativeFontInfo() const
143 wxCHECK_MSG( Ok(), NULL
, wxT("invalid font") );
145 return M_FONTDATA
->GetNativeFontInfo();
148 bool wxFont::GetNoAntiAliasing() const
150 wxCHECK_MSG( Ok(), false, wxT("invalid font") );
152 return M_FONTDATA
->GetNoAntiAliasing();
155 // ----------------------------------------------------------------------------
156 // change font attributes
157 // ----------------------------------------------------------------------------
159 void wxFont::SetPointSize(int pointSize
)
162 M_FONTDATA
->SetPointSize(pointSize
);
165 void wxFont::SetFamily(int family
)
168 M_FONTDATA
->SetFamily(family
);
171 void wxFont::SetStyle(int style
)
174 M_FONTDATA
->SetStyle(style
);
177 void wxFont::SetWeight(int weight
)
180 M_FONTDATA
->SetWeight(weight
);
183 bool wxFont::SetFaceName(const wxString
& faceName
)
186 M_FONTDATA
->SetFaceName(faceName
);
187 return wxFontBase::SetFaceName(faceName
);
190 void wxFont::SetUnderlined(bool underlined
)
193 M_FONTDATA
->SetUnderlined(underlined
);
196 void wxFont::SetEncoding(wxFontEncoding encoding
)
199 M_FONTDATA
->SetEncoding(encoding
);
202 void wxFont::SetNoAntiAliasing(bool no
)
205 M_FONTDATA
->SetNoAntiAliasing(no
);