X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/5dd0719e6a0f277be0169d4f455f40bf189a6a5a..bb996f289574defb0ae4339ae8e46ff3cf6fa54c:/src/osx/carbon/font.cpp diff --git a/src/osx/carbon/font.cpp b/src/osx/carbon/font.cpp index d4a4584722..634453ec6a 100644 --- a/src/osx/carbon/font.cpp +++ b/src/osx/carbon/font.cpp @@ -137,6 +137,8 @@ public: } wxFontEncoding GetEncoding() const { return m_info.GetEncoding(); } + + bool IsFixedWidth() const; void Free(); @@ -272,7 +274,6 @@ wxFontRefData::wxFontRefData(wxOSXSystemFont font, int size) Init(); #if wxOSX_USE_CORE_TEXT - if ( UMAGetSystemVersion() >= 0x1050 ) { CTFontUIFontType uifont = kCTFontSystemFontType; switch( font ) @@ -465,7 +466,6 @@ void wxFontRefData::MacFindFont() m_info.EnsureValid(); #if wxOSX_USE_CORE_TEXT - if ( UMAGetSystemVersion() >= 0x1050 ) { CTFontSymbolicTraits traits = 0; @@ -542,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 // ---------------------------------------------------------------------------- @@ -657,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(); @@ -730,6 +740,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();