X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/4799f3baab3805e51cc1754b89d855d32e94c232..51146826fc0a0a949d88f23fb9d83fc1f1ada14e:/src/cocoa/dc.mm diff --git a/src/cocoa/dc.mm b/src/cocoa/dc.mm index 832b6ba726..a56a4fa6ca 100644 --- a/src/cocoa/dc.mm +++ b/src/cocoa/dc.mm @@ -315,11 +315,25 @@ void wxDC::DoDrawText(const wxString& text, wxCoord x, wxCoord y) NSPoint layoutLocation = [sm_cocoaNSLayoutManager locationForGlyphAtIndex:0]; layoutLocation.x = 0.0; layoutLocation.y *= -1.0; + + // Save the location as is for underlining + NSPoint underlineLocation = layoutLocation; + + // Offset the location by the baseline for drawing the glyphs. layoutLocation.y += [[sm_cocoaNSLayoutManager typesetter] baselineOffsetInLayoutManager:sm_cocoaNSLayoutManager glyphIndex:0]; + if(m_backgroundMode==wxSOLID) [sm_cocoaNSLayoutManager drawBackgroundForGlyphRange:glyphRange atPoint:NSZeroPoint]; [sm_cocoaNSLayoutManager drawGlyphsForGlyphRange:glyphRange atPoint:layoutLocation]; + int underlineStyle = GetFont().GetUnderlined() ? NSUnderlineStyleSingle : NSUnderlineStyleNone; + NSRange lineGlyphRange; + NSRect lineRect = [sm_cocoaNSLayoutManager lineFragmentRectForGlyphAtIndex:0 effectiveRange:&lineGlyphRange]; + + [sm_cocoaNSLayoutManager underlineGlyphRange:glyphRange underlineType:underlineStyle + lineFragmentRect:lineRect lineFragmentGlyphRange:lineGlyphRange + containerOrigin:underlineLocation]; + [context restoreGraphicsState]; } @@ -386,6 +400,11 @@ void wxDC::DoDrawArc(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, wxCoord xc, { } +void wxDC::SetFont(const wxFont& font) +{ + m_font = font; +} + void wxDC::SetPen(const wxPen& pen) { m_pen = pen;