]>
git.saurik.com Git - wxWidgets.git/blob - src/mac/carbon/font.cpp
79d93657fbd3ed0f76f3c06d3e209219ccab2817
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/fontutil.h"
20 #include "wx/gdicmn.h"
22 #include "wx/fontutil.h"
24 #if !USE_SHARED_LIBRARIES
25 IMPLEMENT_DYNAMIC_CLASS(wxFont
, wxGDIObject
)
28 // ============================================================================
30 // ============================================================================
32 // ----------------------------------------------------------------------------
34 // ----------------------------------------------------------------------------
36 void wxFontRefData::Init(int pointSize
,
41 const wxString
& faceName
,
42 wxFontEncoding encoding
)
45 m_pointSize
= pointSize
;
49 m_underlined
= underlined
;
50 m_faceName
= faceName
;
51 m_encoding
= encoding
;
59 wxFontRefData::~wxFontRefData()
63 void wxFontRefData::MacFindFont()
65 if( m_faceName
== "" )
70 m_macFontNum
= ::GetAppFont() ;
73 ::GetFNum( "\pTimes" , &m_macFontNum
) ;
76 ::GetFNum( "\pTimes" , &m_macFontNum
) ;
79 ::GetFNum( "\pTimes" , &m_macFontNum
) ;
82 ::GetFNum( "\pGeneva" , &m_macFontNum
) ;
85 ::GetFNum( "\pMonaco" , &m_macFontNum
) ;
91 if ( m_faceName
== "systemfont" )
92 m_macFontNum
= ::GetSysFont() ;
93 else if ( m_faceName
== "applicationfont" )
94 m_macFontNum
= ::GetAppFont() ;
97 strcpy(wxBuffer
, m_faceName
);
99 ::GetFNum( (unsigned char*) wxBuffer
, &m_macFontNum
);
104 if (m_weight
== wxBOLD
)
105 m_macFontStyle
|= bold
;
106 if (m_style
== wxITALIC
|| m_style
== wxSLANT
)
107 m_macFontStyle
|= italic
;
109 m_macFontStyle
|= underline
;
110 m_macFontSize
= m_pointSize
;
113 // ----------------------------------------------------------------------------
115 // ----------------------------------------------------------------------------
120 wxTheFontList
->Append(this);
123 bool wxFont::Create(const wxNativeFontInfo
& info
)
125 return Create(info
.pointSize
, info
.family
, info
.style
, info
.weight
,
126 info
.underlined
, info
.faceName
, info
.encoding
);
129 wxFont::wxFont(const wxString
& fontdesc
)
131 wxNativeFontInfo info
;
132 if ( info
.FromString(fontdesc
) )
136 bool wxFont::Create(int pointSize
,
141 const wxString
& faceName
,
142 wxFontEncoding encoding
)
145 m_refData
= new wxFontRefData(pointSize
, family
, style
, weight
,
146 underlined
, faceName
, encoding
);
156 wxTheFontList
->DeleteObject(this);
159 bool wxFont::RealizeResource()
161 M_FONTDATA
->MacFindFont() ;
165 void wxFont::SetEncoding(wxFontEncoding encoding
)
169 M_FONTDATA
->m_encoding
= encoding
;
174 void wxFont::Unshare()
176 // Don't change shared data
179 m_refData
= new wxFontRefData();
183 wxFontRefData
* ref
= new wxFontRefData(*(wxFontRefData
*)m_refData
);
189 void wxFont::SetPointSize(int pointSize
)
193 M_FONTDATA
->m_pointSize
= pointSize
;
198 void wxFont::SetFamily(int family
)
202 M_FONTDATA
->m_family
= family
;
207 void wxFont::SetStyle(int style
)
211 M_FONTDATA
->m_style
= style
;
216 void wxFont::SetWeight(int weight
)
220 M_FONTDATA
->m_weight
= weight
;
225 void wxFont::SetFaceName(const wxString
& faceName
)
229 M_FONTDATA
->m_faceName
= faceName
;
234 void wxFont::SetUnderlined(bool underlined
)
238 M_FONTDATA
->m_underlined
= underlined
;
243 // ----------------------------------------------------------------------------
245 // ----------------------------------------------------------------------------
247 int wxFont::GetPointSize() const
249 return M_FONTDATA
->m_pointSize
;
252 int wxFont::GetFamily() const
254 return M_FONTDATA
->m_family
;
257 int wxFont::GetStyle() const
259 return M_FONTDATA
->m_style
;
262 int wxFont::GetWeight() const
264 return M_FONTDATA
->m_weight
;
267 bool wxFont::GetUnderlined() const
269 return M_FONTDATA
->m_underlined
;
272 wxString
wxFont::GetFaceName() const
276 str
= M_FONTDATA
->m_faceName
;
280 wxFontEncoding
wxFont::GetEncoding() const
282 return M_FONTDATA
->m_encoding
;