X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/a47ae718e2211f64a44eb1238f7e8594c5c3f01b..b635e17fef75d05881f5b5db85ec5f21d1cb3750:/src/mac/carbon/dc.cpp diff --git a/src/mac/carbon/dc.cpp b/src/mac/carbon/dc.cpp index d830f68a1e..bfd36c8421 100644 --- a/src/mac/carbon/dc.cpp +++ b/src/mac/carbon/dc.cpp @@ -1371,11 +1371,10 @@ void wxDC::DoDrawRotatedText(const wxString& str, wxCoord x, wxCoord y, wxMacFastPortSetter helper(this) ; MacInstallFont() ; - wxFontRefData * font = (wxFontRefData*) m_font.GetRefData() ; if ( 0 ) { m_macFormerAliasState = IsAntiAliasedTextEnabled(&m_macFormerAliasSize); - SetAntiAliasedTextEnabled(true, SInt16(m_scaleY * font->m_macFontSize)); + SetAntiAliasedTextEnabled(true, SInt16(m_scaleY * m_font.GetMacFontSize())); m_macAliasWasEnabled = true ; } OSStatus status = noErr ; @@ -1486,7 +1485,7 @@ void wxDC::DoDrawText(const wxString& strtext, wxCoord x, wxCoord y) if ( useDrawThemeText ) { Rect frame = { yy + line*(fi.descent + fi.ascent + fi.leading) ,xx , yy + (line+1)*(fi.descent + fi.ascent + fi.leading) , xx + 10000 } ; - wxMacCFStringHolder mString( linetext ) ; + wxMacCFStringHolder mString( linetext , m_font.GetEncoding() ) ; if ( m_backgroundMode != wxTRANSPARENT ) { Point bounds={0,0} ; @@ -1528,7 +1527,7 @@ void wxDC::DoDrawText(const wxString& strtext, wxCoord x, wxCoord y) if ( useDrawThemeText ) { Rect frame = { yy + line*(fi.descent + fi.ascent + fi.leading) ,xx , yy + (line+1)*(fi.descent + fi.ascent + fi.leading) , xx + 10000 } ; - wxMacCFStringHolder mString( linetext ) ; + wxMacCFStringHolder mString( linetext , m_font.GetEncoding()) ; if ( m_backgroundMode != wxTRANSPARENT ) { @@ -1615,7 +1614,7 @@ void wxDC::DoGetTextExtent( const wxString &strtext, wxCoord *width, wxCoord *h { Point bounds={0,0} ; SInt16 baseline ; - wxMacCFStringHolder mString( linetext ) ; + wxMacCFStringHolder mString( linetext , m_font.GetEncoding() ) ; ::GetThemeTextDimensions( mString, kThemeCurrentPortFont, kThemeStateActive, @@ -1643,7 +1642,7 @@ void wxDC::DoGetTextExtent( const wxString &strtext, wxCoord *width, wxCoord *h { Point bounds={0,0} ; SInt16 baseline ; - wxMacCFStringHolder mString( linetext ) ; + wxMacCFStringHolder mString( linetext , m_font.GetEncoding() ) ; ::GetThemeTextDimensions( mString, kThemeCurrentPortFont, kThemeStateActive, @@ -1669,6 +1668,68 @@ void wxDC::DoGetTextExtent( const wxString &strtext, wxCoord *width, wxCoord *h } } + +bool wxDC::DoGetPartialTextExtents(const wxString& text, wxArrayInt& widths) const +{ + wxCHECK_MSG(Ok(), false, wxT("Invalid DC")); + + widths.Empty(); + widths.Add(0, text.Length()); + + if (text.Length() == 0) + return false; + + wxMacFastPortSetter helper(this) ; + MacInstallFont() ; +#if TARGET_CARBON + bool useGetThemeText = ( GetThemeTextDimensions != (void*) kUnresolvedCFragSymbolAddress ) ; + if ( UMAGetSystemVersion() < 0x1000 || IsKindOf(CLASSINFO( wxPrinterDC ) ) || ((wxFont*)&m_font)->GetNoAntiAliasing() ) + useGetThemeText = false ; + + if ( useGetThemeText ) + { + // If anybody knows how to do this more efficiently yet still handle + // the fractional glyph widths that may be present when using AA + // fonts, please change it. Currently it is measuring from the + // begining of the string for each succeding substring, which is much + // slower than this should be. + for (size_t i=0; iGetNoAntiAliasing() ) useGetThemeText = false ; #endif - char text[] = "H" ; + char text[] = "g" ; #if TARGET_CARBON if ( useGetThemeText ) { @@ -1735,12 +1796,11 @@ void wxDC::MacInstallFont() const // return ; Pattern blackColor ; MacSetupBackgroundForCurrentPort(m_backgroundBrush) ; - wxFontRefData * font = (wxFontRefData*) m_font.GetRefData() ; - if ( font ) + if ( m_font.Ok() ) { - ::TextFont( font->m_macFontNum ) ; - ::TextSize( short(m_scaleY * font->m_macFontSize) ) ; - ::TextFace( font->m_macFontStyle ) ; + ::TextFont( m_font.GetMacFontNum() ) ; + ::TextSize( (short)(m_scaleY * m_font.GetMacFontSize()) ) ; + ::TextFace( m_font.GetMacFontStyle() ) ; m_macFontInstalled = true ; m_macBrushInstalled = false ; m_macPenInstalled = false ; @@ -1809,9 +1869,9 @@ void wxDC::MacInstallFont() const } ::PenMode( mode ) ; OSStatus status = noErr ; - Fixed atsuSize = IntToFixed( int(m_scaleY * font->m_macFontSize) ) ; - Style qdStyle = font->m_macFontStyle ; - ATSUFontID atsuFont = font->m_macATSUFontID ; + Fixed atsuSize = IntToFixed( int(m_scaleY * m_font.GetMacFontSize()) ) ; + Style qdStyle = m_font.GetMacFontStyle() ; + ATSUFontID atsuFont = m_font.GetMacATSUFontID() ; status = ::ATSUCreateStyle((ATSUStyle *)&m_macATSUIStyle) ; wxASSERT_MSG( status == noErr , wxT("couldn't create ATSU style") ) ; ATSUAttributeTag atsuTags[] =