]>
git.saurik.com Git - wxWidgets.git/blob - src/mac/carbon/font.cpp
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxFont class
8 // Copyright: (c) AUTHOR
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "font.h"
17 #include "wx/string.h"
19 #include "wx/gdicmn.h"
21 #include "wx/fontutil.h"
23 #if !USE_SHARED_LIBRARIES
24 IMPLEMENT_DYNAMIC_CLASS(wxFont
, wxGDIObject
)
27 // ============================================================================
29 // ============================================================================
31 // ----------------------------------------------------------------------------
33 // ----------------------------------------------------------------------------
35 void wxFontRefData::Init(int pointSize
,
40 const wxString
& faceName
,
41 wxFontEncoding encoding
)
44 m_pointSize
= pointSize
;
48 m_underlined
= underlined
;
49 m_faceName
= faceName
;
50 m_encoding
= encoding
;
58 wxFontRefData::~wxFontRefData()
62 void wxFontRefData::MacFindFont()
64 if( m_faceName
== "" )
69 m_macFontNum
= ::GetAppFont() ;
72 ::GetFNum( "\pTimes" , &m_macFontNum
) ;
75 ::GetFNum( "\pTimes" , &m_macFontNum
) ;
78 ::GetFNum( "\pTimes" , &m_macFontNum
) ;
81 ::GetFNum( "\pGeneva" , &m_macFontNum
) ;
84 ::GetFNum( "\pMonaco" , &m_macFontNum
) ;
90 if ( m_faceName
== "systemfont" )
91 m_macFontNum
= ::GetSysFont() ;
92 else if ( m_faceName
== "applicationfont" )
93 m_macFontNum
= ::GetAppFont() ;
96 strcpy(wxBuffer
, m_faceName
);
98 ::GetFNum( (unsigned char*) wxBuffer
, &m_macFontNum
);
103 if (m_weight
== wxBOLD
)
104 m_macFontStyle
|= bold
;
105 if (m_style
== wxITALIC
|| m_style
== wxSLANT
)
106 m_macFontStyle
|= italic
;
108 m_macFontStyle
|= underline
;
109 m_macFontSize
= m_pointSize
;
112 // ----------------------------------------------------------------------------
114 // ----------------------------------------------------------------------------
119 wxTheFontList
->Append(this);
122 wxFont::wxFont(const wxString
& fontdesc
)
124 wxNativeFontInfo info
;
125 if ( info
.FromString(fontdesc
) )
129 bool wxFont::Create(int pointSize
,
134 const wxString
& faceName
,
135 wxFontEncoding encoding
)
138 m_refData
= new wxFontRefData(pointSize
, family
, style
, weight
,
139 underlined
, faceName
, encoding
);
146 bool wxFont::Create(const wxNativeFontInfo
& info
)
148 return Create(info
.pointSize
, info
.family
, info
.style
, info
.weight
,
149 info
.underlined
, info
.faceName
, info
.encoding
);
155 wxTheFontList
->DeleteObject(this);
158 bool wxFont::RealizeResource()
160 M_FONTDATA
->MacFindFont() ;
164 void wxFont::SetEncoding(wxFontEncoding encoding
)
168 M_FONTDATA
->m_encoding
= encoding
;
173 void wxFont::Unshare()
175 // Don't change shared data
178 m_refData
= new wxFontRefData();
182 wxFontRefData
* ref
= new wxFontRefData(*(wxFontRefData
*)m_refData
);
188 void wxFont::SetPointSize(int pointSize
)
192 M_FONTDATA
->m_pointSize
= pointSize
;
197 void wxFont::SetFamily(int family
)
201 M_FONTDATA
->m_family
= family
;
206 void wxFont::SetStyle(int style
)
210 M_FONTDATA
->m_style
= style
;
215 void wxFont::SetWeight(int weight
)
219 M_FONTDATA
->m_weight
= weight
;
224 void wxFont::SetFaceName(const wxString
& faceName
)
228 M_FONTDATA
->m_faceName
= faceName
;
233 void wxFont::SetUnderlined(bool underlined
)
237 M_FONTDATA
->m_underlined
= underlined
;
242 // ----------------------------------------------------------------------------
244 // ----------------------------------------------------------------------------
246 int wxFont::GetPointSize() const
248 return M_FONTDATA
->m_pointSize
;
251 int wxFont::GetFamily() const
253 return M_FONTDATA
->m_family
;
256 int wxFont::GetStyle() const
258 return M_FONTDATA
->m_style
;
261 int wxFont::GetWeight() const
263 return M_FONTDATA
->m_weight
;
266 bool wxFont::GetUnderlined() const
268 return M_FONTDATA
->m_underlined
;
271 wxString
wxFont::GetFaceName() const
275 str
= M_FONTDATA
->m_faceName
;
279 wxFontEncoding
wxFont::GetEncoding() const
281 return M_FONTDATA
->m_encoding
;