From 40d7afd81cc85eb8bf870d3444a81e7abed41b89 Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Wed, 14 May 2008 20:40:54 +0000 Subject: [PATCH] fix clipping of Mac OS X text drawing(!) when not kerning svn: r9834 --- src/wxmac/src/mac/wx_dccan3.cc | 41 +++++++++++++++++++++++++--------- 1 file changed, 30 insertions(+), 11 deletions(-) diff --git a/src/wxmac/src/mac/wx_dccan3.cc b/src/wxmac/src/mac/wx_dccan3.cc index 9fa6e5166b..9f88d4d9e3 100644 --- a/src/wxmac/src/mac/wx_dccan3.cc +++ b/src/wxmac/src/mac/wx_dccan3.cc @@ -142,6 +142,27 @@ static short cgf_txFont, cgf_txFace; 4-bit pixel-aligned anti-aliasing (the old QuickDraw standard). */ extern "C" void CGContextSetFontRenderingMode(CGContextRef cg, int v); +//----------------------------------------------------------------------------- + +static RgnHandle GetCurrentClipRgn(CGrafPtr qdp) +{ + RgnHandle clipRgn; + + clipRgn = NewRgn(); + if (clipRgn) { + RgnHandle visRgn; + visRgn = NewRgn(); + if (visRgn) { + GetPortClipRegion(qdp, clipRgn); + GetPortVisibleRegion(qdp, visRgn); + SectRgn(clipRgn, visRgn, clipRgn); + DisposeRgn(visRgn); + } + } + + return clipRgn; +} + //----------------------------------------------------------------------------- void wxCanvasDC::DrawText(const char* text, double x, double y, Bool combine, Bool ucs4, int d, double angle) { @@ -294,6 +315,14 @@ void wxCanvasDC::DrawText(const char* text, double x, double y, Bool combine, Bo qdp = cMacDC->macGrafPort(); SyncCGContextOriginWithPort(cg, qdp); GetPortBounds(qdp, &portRect); + { + RgnHandle clipRgn; + clipRgn = GetCurrentClipRgn(qdp); + if (clipRgn) { + ClipCGContextToRegion(cg, &portRect, clipRgn); + DisposeRgn(clipRgn); + } + } CGContextTranslateCTM(cg, gdx + (x * user_scale_x) + device_origin_x, (portRect.bottom - portRect.top) @@ -947,17 +976,7 @@ static double DrawMeasUnicodeText(const char *text, int d, int theStrlen, int uc if (use_cgctx) { /* Make clipping regions match (including BeginUpdate effect) */ - clipRgn = NewRgn(); - if (clipRgn) { - RgnHandle visRgn; - visRgn = NewRgn(); - if (visRgn) { - GetPortClipRegion(qdp, clipRgn); - GetPortVisibleRegion(qdp, visRgn); - SectRgn(clipRgn, visRgn, clipRgn); - DisposeRgn(visRgn); - } - } + clipRgn = GetCurrentClipRgn(qdp); } else clipRgn = NULL; } else