X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e5e5b843dd206e71f958b084bbc41497a5e283fc..47e175a24f862aa8b7ca7dd4a2bb5957991e7f2d:/src/osx/carbon/font.cpp?ds=sidebyside diff --git a/src/osx/carbon/font.cpp b/src/osx/carbon/font.cpp index dd3d6d4222..634453ec6a 100644 --- a/src/osx/carbon/font.cpp +++ b/src/osx/carbon/font.cpp @@ -31,8 +31,6 @@ #include #include -IMPLEMENT_DYNAMIC_CLASS(wxFont, wxGDIObject) - class WXDLLEXPORT wxFontRefData: public wxGDIRefData { public: @@ -139,6 +137,8 @@ public: } wxFontEncoding GetEncoding() const { return m_info.GetEncoding(); } + + bool IsFixedWidth() const; void Free(); @@ -177,7 +177,7 @@ public: #define M_FONTDATA ((wxFontRefData*)m_refData) -wxFontRefData::wxFontRefData(const wxFontRefData& data) +wxFontRefData::wxFontRefData(const wxFontRefData& data) : wxGDIRefData() { Init(); m_info = data.m_info; @@ -274,7 +274,6 @@ wxFontRefData::wxFontRefData(wxOSXSystemFont font, int size) Init(); #if wxOSX_USE_CORE_TEXT - if ( UMAGetSystemVersion() >= 0x1050 ) { CTFontUIFontType uifont = kCTFontSystemFontType; switch( font ) @@ -467,7 +466,6 @@ void wxFontRefData::MacFindFont() m_info.EnsureValid(); #if wxOSX_USE_CORE_TEXT - if ( UMAGetSystemVersion() >= 0x1050 ) { CTFontSymbolicTraits traits = 0; @@ -477,7 +475,7 @@ void wxFontRefData::MacFindFont() traits |= kCTFontItalicTrait; // use font caching - wxString lookupnameWithSize = wxString::Format( "%s_%ld_%ld", m_info.m_faceName.c_str(), traits, m_info.m_pointSize ); + wxString lookupnameWithSize = wxString::Format( "%s_%u_%d", m_info.m_faceName, traits, m_info.m_pointSize ); static std::map< std::wstring , wxCFRef< CTFontRef > > fontcache ; m_ctFont = fontcache[ std::wstring(lookupnameWithSize.wc_str()) ]; @@ -499,7 +497,7 @@ void wxFontRefData::MacFindFont() { CTFontSymbolicTraits remainingTraits = traits; const CGAffineTransform* remainingTransform = NULL; - + if( remainingTraits & kCTFontItalicTrait ) { remainingTraits &= ~kCTFontItalicTrait; @@ -515,19 +513,19 @@ void wxFontRefData::MacFindFont() } } } - + if ( fontWithTraits == NULL ) { fontWithTraits = CTFontCreateWithName( wxCFStringRef(m_info.m_faceName), m_info.m_pointSize, remainingTransform ); } - + } if ( fontWithTraits != NULL ) m_ctFont.reset(fontWithTraits); } } } - + m_cgFont.reset(CTFontCopyGraphicsFont(m_ctFont, NULL)); } @@ -544,6 +542,16 @@ void wxFontRefData::MacFindFont() m_fontValid = true; } +bool wxFontRefData::IsFixedWidth() const +{ +#if wxOSX_USE_CORE_TEXT + CTFontSymbolicTraits traits = CTFontGetSymbolicTraits(m_ctFont); + return (traits & kCTFontMonoSpaceTrait) != 0; +#else + return false; +#endif +} + // ---------------------------------------------------------------------------- // wxFont // ---------------------------------------------------------------------------- @@ -659,7 +667,7 @@ wxGDIRefData *wxFont::CloneGDIRefData(const wxGDIRefData *data) const void wxFont::SetPointSize(int pointSize) { - if ( M_FONTDATA->GetPointSize() == pointSize ) + if ( M_FONTDATA != NULL && M_FONTDATA->GetPointSize() == pointSize ) return; AllocExclusive(); @@ -732,10 +740,18 @@ wxSize wxFont::GetPixelSize() const #endif } -wxFontFamily wxFont::GetFamily() const +bool wxFont::IsFixedWidth() const { - wxCHECK_MSG( M_FONTDATA != NULL , wxFONTFAMILY_MAX, wxT("invalid font") ); + wxCHECK_MSG( M_FONTDATA != NULL , false, wxT("invalid font") ); + + // cast away constness otherwise lazy font resolution is not possible + const_cast(this)->RealizeResource(); + + return M_FONTDATA->IsFixedWidth(); +} +wxFontFamily wxFont::DoGetFamily() const +{ return M_FONTDATA->GetFamily(); } @@ -816,7 +832,6 @@ void * wxFont::MacGetATSUStyle() const return M_FONTDATA->m_macATSUStyle; } -#if WXWIN_COMPATIBILITY_2_8 wxUint32 wxFont::MacGetATSUFontID() const { wxCHECK_MSG( M_FONTDATA != NULL, 0, wxT("invalid font") ); @@ -838,8 +853,6 @@ wxUint32 wxFont::MacGetATSUAdditionalQDStyles() const } #endif -#endif - #if wxOSX_USE_CORE_TEXT CTFontRef wxFont::OSXGetCTFont() const @@ -888,10 +901,10 @@ NSFont* wxFont::OSXGetNSFont() const UIFont* wxFont::OSXGetUIFont() const { wxCHECK_MSG( M_FONTDATA != NULL , 0, wxT("invalid font") ); - + // cast away constness otherwise lazy font resolution is not possible const_cast(this)->RealizeResource(); - + return (M_FONTDATA->m_uiFont); } @@ -900,7 +913,7 @@ UIFont* wxFont::OSXGetUIFont() const const wxNativeFontInfo * wxFont::GetNativeFontInfo() const { wxCHECK_MSG( M_FONTDATA != NULL , NULL, wxT("invalid font") ); - wxCHECK_MSG( Ok(), NULL, wxT("invalid font") ); + wxCHECK_MSG( IsOk(), NULL, wxT("invalid font") ); // cast away constness otherwise lazy font resolution is not possible const_cast(this)->RealizeResource(); @@ -1224,6 +1237,12 @@ wxFontEncoding wxNativeFontInfo::GetEncoding() const return m_encoding; } +bool wxNativeFontInfo::GetStrikethrough() const +{ + return false; +} + + // changing the font descriptor void wxNativeFontInfo::SetPointSize(int pointsize) @@ -1288,3 +1307,9 @@ void wxNativeFontInfo::SetEncoding(wxFontEncoding encoding_) m_encoding = encoding_; // not reflected in native descriptors } + +void wxNativeFontInfo::SetStrikethrough(bool WXUNUSED(strikethrough)) +{ +} + +