diff --git a/include/wx/osx/core/cfdictionary.h b/include/wx/osx/core/cfdictionary.h index fddbb52654..d27c0f5891 100644 --- a/include/wx/osx/core/cfdictionary.h +++ b/include/wx/osx/core/cfdictionary.h @@ -90,6 +90,11 @@ public: { return CFDictionaryCreateCopy(kCFAllocatorDefault, this->m_ptr); } + + CFMutableDictionaryRef CreateMutableCopy() const + { + return CFDictionaryCreateMutableCopy(kCFAllocatorDefault, 0, this->m_ptr); + } }; class wxCFMutableDictionaryRef : public wxCFDictionaryRefCommon diff --git a/src/osx/carbon/graphics.cpp b/src/osx/carbon/graphics.cpp index cd99421373..16f58329da 100644 --- a/src/osx/carbon/graphics.cpp +++ b/src/osx/carbon/graphics.cpp @@ -39,6 +39,7 @@ #include "wx/osx/dcclient.h" #include "wx/osx/dcmemory.h" #include "wx/osx/private.h" + #include "wx/osx/core/cfdictionary.h" #else #include "CoreServices/CoreServices.h" #include "ApplicationServices/ApplicationServices.h" @@ -2298,7 +2299,23 @@ void wxMacCoreGraphicsContext::DoDrawText( const wxString &str, wxDouble x, wxDo CGColorRef col = wxMacCreateCGColor( fref->GetColour() ); CTFontRef font = fref->OSXGetCTFont(); - wxCFRef attrtext( CFAttributedStringCreate(kCFAllocatorDefault, text, fref->OSXGetCTFontAttributes()) ); + wxCFDictionaryRef fontattr(wxCFRetain(fref->OSXGetCTFontAttributes())); + wxCFMutableDictionaryRef inlinefontattr; + + bool setColorsInLine = false; + + // if we emulate boldness the stroke color is not taken from the current context + // therefore we have to set it explicitly + if ( fontattr.GetValue(kCTStrokeWidthAttributeName) != NULL) + { + setColorsInLine = true; + inlinefontattr = fontattr.CreateMutableCopy(); + inlinefontattr.SetValue(kCTForegroundColorFromContextAttributeName, kCFBooleanFalse); + inlinefontattr.SetValue(kCTForegroundColorAttributeName,col); + inlinefontattr.SetValue(kCTStrokeColorAttributeName,col); + } + + wxCFRef attrtext( CFAttributedStringCreate(kCFAllocatorDefault, text, setColorsInLine ? inlinefontattr : fontattr ) ); wxCFRef line( CTLineCreateWithAttributedString(attrtext) ); y += CTFontGetAscent(font);