X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/ea2807a4c4a0949ff78503ec86ec20a2d238a1f3..cdbd62d6ff290fd58acd1bc5574dfc79db3a6f70:/src/osx/carbon/font.cpp diff --git a/src/osx/carbon/font.cpp b/src/osx/carbon/font.cpp index 5a1b9bae8b..ce2de44c54 100644 --- a/src/osx/carbon/font.cpp +++ b/src/osx/carbon/font.cpp @@ -4,7 +4,6 @@ // Author: Stefan Csomor // Modified by: // Created: 1998-01-01 -// RCS-ID: $Id$ // Copyright: (c) Stefan Csomor // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -137,6 +136,8 @@ public: } wxFontEncoding GetEncoding() const { return m_info.GetEncoding(); } + + bool IsFixedWidth() const; void Free(); @@ -272,7 +273,6 @@ wxFontRefData::wxFontRefData(wxOSXSystemFont font, int size) Init(); #if wxOSX_USE_CORE_TEXT - if ( UMAGetSystemVersion() >= 0x1050 ) { CTFontUIFontType uifont = kCTFontSystemFontType; switch( font ) @@ -465,7 +465,6 @@ void wxFontRefData::MacFindFont() m_info.EnsureValid(); #if wxOSX_USE_CORE_TEXT - if ( UMAGetSystemVersion() >= 0x1050 ) { CTFontSymbolicTraits traits = 0; @@ -542,6 +541,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 // ---------------------------------------------------------------------------- @@ -657,7 +666,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(); @@ -730,6 +739,16 @@ wxSize wxFont::GetPixelSize() const #endif } +bool wxFont::IsFixedWidth() const +{ + 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(); @@ -893,7 +912,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(); @@ -1092,7 +1111,16 @@ void wxNativeFontInfo::Init(int size, wxFontEncoding encoding) { Init(); - m_pointSize = size; + + // We should use the default font size if the special value wxDEFAULT is + // specified and we also handle -1 as a synonym for wxDEFAULT for + // compatibility with wxGTK (see #12541). + // + // Notice that we rely on the fact that wxNORMAL_FONT itself is not + // initialized using this ctor, but from native font info. + m_pointSize = size == -1 || size == wxDEFAULT + ? wxNORMAL_FONT->GetPointSize() + : size; m_family = family; m_style = style; m_weight = weight; @@ -1217,6 +1245,12 @@ wxFontEncoding wxNativeFontInfo::GetEncoding() const return m_encoding; } +bool wxNativeFontInfo::GetStrikethrough() const +{ + return false; +} + + // changing the font descriptor void wxNativeFontInfo::SetPointSize(int pointsize) @@ -1281,3 +1315,9 @@ void wxNativeFontInfo::SetEncoding(wxFontEncoding encoding_) m_encoding = encoding_; // not reflected in native descriptors } + +void wxNativeFontInfo::SetStrikethrough(bool WXUNUSED(strikethrough)) +{ +} + +