}
wxFontRefData(int size,
- int family,
- int style,
- int weight,
+ wxFontFamily family,
+ wxFontStyle style,
+ wxFontWeight weight,
bool underlined,
const wxString& faceName,
wxFontEncoding encoding)
int GetPointSize() const { return m_pointSize; }
- void SetFamily( int family )
+ void SetFamily( wxFontFamily family )
{
m_family = family;
MacInvalidateNativeFont();
int GetFamily() const { return m_family; }
- void SetStyle( int style )
+ void SetStyle( wxFontStyle style )
{
m_style = style;
MacInvalidateNativeFont();
int GetStyle() const { return m_style; }
- void SetWeight( int weight )
+ void SetWeight( wxFontWeight weight )
{
m_weight = weight;
MacInvalidateNativeFont();
protected:
// common part of all ctors
void Init(int size,
- int family,
- int style,
- int weight,
+ wxFontFamily family,
+ wxFontStyle style,
+ wxFontWeight weight,
bool underlined,
const wxString& faceName,
wxFontEncoding encoding);
#endif
// font characterstics
int m_pointSize;
- int m_family;
- int m_style;
- int m_weight;
+ wxFontFamily m_family;
+ wxFontStyle m_style;
+ wxFontWeight m_weight;
bool m_underlined;
wxString m_faceName;
wxFontEncoding m_encoding;
// ----------------------------------------------------------------------------
void wxFontRefData::Init(int pointSize,
- int family,
- int style,
- int weight,
+ wxFontFamily family,
+ wxFontStyle style,
+ wxFontWeight weight,
bool underlined,
const wxString& faceName,
wxFontEncoding encoding)
}
}
-
+
CTFontSymbolicTraits traits = 0;
if (m_weight == wxBOLD)
traits |= kCTFontBoldTrait;
if (m_style == wxITALIC || m_style == wxSLANT)
traits |= kCTFontItalicTrait;
-
+
// use font caching
wxString lookupnameWithSize = wxString::Format( "%s_%ld_%ld", m_faceName.c_str(), traits, m_pointSize );
-
+
static std::map< std::wstring , wxCFRef< CTFontRef > > fontcache ;
m_ctFont = fontcache[ std::wstring(lookupnameWithSize.wc_str()) ];
if ( !m_ctFont )
qdstyle |= bold;
if (m_style == wxITALIC || m_style == wxSLANT)
qdstyle |= italic;
-
+
Str255 qdFontName ;
wxMacStringToPascal( m_faceName , qdFontName );
m_ctFont.reset( CTFontCreateWithQuickdrawInstance(qdFontName, 0 , qdstyle, m_pointSize) );
// TODO further fallbacks, synthesizing bold and italic, trying direct PostScript names etc
}
}
-
+
fontcache[ std::wstring(lookupnameWithSize.wc_str()) ] = m_ctFont;
#if 1 // debugging coretext font matching
CTFontSymbolicTraits received = CTFontGetSymbolicTraits( m_ctFont ) & 0x03;
CFShow( dict );
CFRelease( dict );
}
-#endif
+#endif
}
}
}
bool wxFont::Create(int pointSize,
- int family,
- int style,
- int weight,
- bool underlined,
- const wxString& faceName,
- wxFontEncoding encoding)
+ wxFontFamily family,
+ wxFontStyle style,
+ wxFontWeight weight,
+ bool underlined,
+ const wxString& faceName,
+ wxFontEncoding encoding)
{
UnRef();
wxGDIRefData *wxFont::CloneGDIRefData(const wxGDIRefData *data) const
{
- return new wxFontRefData(*wx_static_cast(const wxFontRefData *, data));
+ return new wxFontRefData(*static_cast<const wxFontRefData *>(data));
}
void wxFont::SetPointSize(int pointSize)
RealizeResource();
}
-void wxFont::SetFamily(int family)
+void wxFont::SetFamily(wxFontFamily family)
{
Unshare();
RealizeResource();
}
-void wxFont::SetStyle(int style)
+void wxFont::SetStyle(wxFontStyle style)
{
Unshare();
RealizeResource();
}
-void wxFont::SetWeight(int weight)
+void wxFont::SetWeight(wxFontWeight weight)
{
Unshare();
#endif
}
-int wxFont::GetFamily() const
+wxFontFamily wxFont::GetFamily() const
{
- wxCHECK_MSG( M_FONTDATA != NULL , 0, wxT("invalid font") );
+ wxCHECK_MSG( M_FONTDATA != NULL , wxFONTFAMILY_MAX, wxT("invalid font") );
return M_FONTDATA->GetFamily();
}
-int wxFont::GetStyle() const
+wxFontStyle wxFont::GetStyle() const
{
- wxCHECK_MSG( M_FONTDATA != NULL , 0, wxT("invalid font") );
+ wxCHECK_MSG( M_FONTDATA != NULL , wxFONTSTYLE_MAX, wxT("invalid font") );
return M_FONTDATA->GetStyle() ;
}
-int wxFont::GetWeight() const
+wxFontWeight wxFont::GetWeight() const
{
- wxCHECK_MSG( M_FONTDATA != NULL , 0, wxT("invalid font") );
+ wxCHECK_MSG( M_FONTDATA != NULL , wxFONTWEIGHT_MAX, wxT("invalid font") );
return M_FONTDATA->GetWeight();
}