X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/beb2638a997914bd12c55e81589adebd90af9ed2..c443ff6f5350df36902af42d0193e53d79dd6a14:/src/osx/carbon/font.cpp diff --git a/src/osx/carbon/font.cpp b/src/osx/carbon/font.cpp index de2fbe7024..2b51a315a1 100644 --- a/src/osx/carbon/font.cpp +++ b/src/osx/carbon/font.cpp @@ -209,7 +209,7 @@ wxFontRefData::wxFontRefData(const wxFontRefData& data) m_nsFont = (NSFont*) wxMacCocoaRetain(data.m_nsFont); #endif #if wxOSX_USE_IPHONE - m_uiFont = wxMacCocoaRetain(data.m_uiFont); + m_uiFont = (UIFont*) wxMacCocoaRetain(data.m_uiFont); #endif } @@ -283,7 +283,7 @@ wxFontRefData::wxFontRefData(wxOSXSystemFont font, int size) #if wxOSX_USE_CORE_TEXT if ( UMAGetSystemVersion() >= 0x1050 ) { - CTFontUIFontType uifont; + CTFontUIFontType uifont = kCTFontSystemFontType; switch( font ) { case wxOSX_SYSTEM_FONT_NORMAL: @@ -323,7 +323,7 @@ wxFontRefData::wxFontRefData(wxOSXSystemFont font, int size) { #if !wxOSX_USE_CARBON // not needed outside - ThemeFontID m_macThemeFontID; + ThemeFontID m_macThemeFontID = kThemeSystemFont; #endif switch( font ) { @@ -384,10 +384,10 @@ wxFontRefData::wxFontRefData(wxOSXSystemFont font, int size) } #endif #if wxOSX_USE_COCOA - m_nsFont = wxFont::CreateNSFont( font, &m_info ); + m_nsFont = wxFont::OSXCreateNSFont( font, &m_info ); #endif #if wxOSX_USE_IPHONE - m_uiFont = wxFont::CreateUIFont( font, &m_info ); + m_uiFont = wxFont::OSXCreateUIFont( font, &m_info ); #endif } @@ -483,10 +483,10 @@ void wxFontRefData::MacFindFont() } #endif #if wxOSX_USE_COCOA - m_nsFont = wxFont::CreateNSFont( &m_info ); + m_nsFont = wxFont::OSXCreateNSFont( &m_info ); #endif #if wxOSX_USE_IPHONE - m_uiFont = wxFont::CreateUIFont( &m_info ); + m_uiFont = wxFont::OSXCreateUIFont( &m_info ); #endif m_fontValid = true; } @@ -576,6 +576,14 @@ wxFont::~wxFont() { } +void wxFont::DoSetNativeFontInfo(const wxNativeFontInfo& info) +{ + UnRef(); + + m_refData = new wxFontRefData( info); +} + + bool wxFont::RealizeResource() { M_FONTDATA->MacFindFont(); @@ -772,11 +780,34 @@ void * wxFont::MacGetATSUStyle() const return M_FONTDATA->m_macATSUStyle; } + +#if WXWIN_COMPATIBILITY_2_8 +wxUint32 wxFont::MacGetATSUFontID() const +{ + wxCHECK_MSG( M_FONTDATA != NULL , NULL, wxT("invalid font") ); + + // cast away constness otherwise lazy font resolution is not possible + const_cast(this)->RealizeResource(); + + return M_FONTDATA->m_info.m_atsuFontID; +} + +wxUint32 wxFont::MacGetATSUAdditionalQDStyles() const +{ + wxCHECK_MSG( M_FONTDATA != NULL , NULL, wxT("invalid font") ); + + // cast away constness otherwise lazy font resolution is not possible + const_cast(this)->RealizeResource(); + + return M_FONTDATA->m_info.m_atsuAdditionalQDStyles; +} +#endif + #endif #if wxOSX_USE_CORE_TEXT -CTFontRef wxFont::GetCTFont() const +CTFontRef wxFont::OSXGetCTFont() const { wxCHECK_MSG( M_FONTDATA != NULL , 0, wxT("invalid font") ); @@ -790,7 +821,7 @@ CTFontRef wxFont::GetCTFont() const #if wxOSX_USE_COCOA_OR_CARBON -CGFontRef wxFont::GetCGFont() const +CGFontRef wxFont::OSXGetCGFont() const { wxCHECK_MSG( M_FONTDATA != NULL , 0, wxT("invalid font") ); @@ -805,7 +836,7 @@ CGFontRef wxFont::GetCGFont() const #if wxOSX_USE_COCOA -NSFont* wxFont::GetNSFont() const +NSFont* wxFont::OSXGetNSFont() const { wxCHECK_MSG( M_FONTDATA != NULL , 0, wxT("invalid font") ); @@ -908,9 +939,6 @@ void wxNativeFontInfo::Init() #endif #if wxOSX_USE_COCOA m_nsFontDescriptor = NULL; -#endif -#if wxOSX_USE_IPHONE - m_uiFontDescriptor = NULL; #endif m_pointSize = 0; m_family = wxFONTFAMILY_DEFAULT; @@ -918,7 +946,7 @@ void wxNativeFontInfo::Init() m_weight = wxFONTWEIGHT_NORMAL; m_underlined = false; m_faceName.clear(); - m_encoding = wxFONTENCODING_DEFAULT; + m_encoding = wxFont::GetDefaultEncoding(); m_descriptorValid = false; } @@ -1034,7 +1062,7 @@ void wxNativeFontInfo::EnsureValid() #endif #if wxOSX_USE_COCOA if ( m_nsFontDescriptor == NULL ) - ValidateNSFontDescriptor(); + OSXValidateNSFontDescriptor(); #endif #if wxOSX_USE_IPHONE // TODO @@ -1059,9 +1087,6 @@ void wxNativeFontInfo::Init(const wxNativeFontInfo& info) #endif #if wxOSX_USE_COCOA m_nsFontDescriptor = (NSFontDescriptor*) wxMacCocoaRetain(info.m_nsFontDescriptor); -#endif -#if wxOSX_USE_IPHONE - m_uiFontDescriptor = wxMacCocoaRetain(info.m_uiFontDescriptor);; #endif m_pointSize = info.m_pointSize; m_family = info.m_family; @@ -1088,6 +1113,8 @@ void wxNativeFontInfo::Init(int size, m_weight = weight; m_underlined = underlined; m_faceName = faceName; + if ( encoding == wxFONTENCODING_DEFAULT ) + encoding = wxFont::GetDefaultEncoding(); m_encoding = encoding; } @@ -1106,10 +1133,6 @@ void wxNativeFontInfo::Free() #if wxOSX_USE_COCOA wxMacCocoaRelease(m_nsFontDescriptor); m_nsFontDescriptor = NULL; -#endif -#if wxOSX_USE_IPHONE - wxMacCocoaRelease(m_uiFontDescriptor); - m_uiFontDescriptor = NULL #endif m_descriptorValid = false; } @@ -1276,6 +1299,8 @@ void wxNativeFontInfo::SetFamily(wxFontFamily family_) void wxNativeFontInfo::SetEncoding(wxFontEncoding encoding_) { + if ( encoding_ == wxFONTENCODING_DEFAULT ) + encoding_ = wxFont::GetDefaultEncoding(); m_encoding = encoding_; // not reflected in native descriptors } \ No newline at end of file