From ddb029aa772014b1761676e7239985251a597c5d Mon Sep 17 00:00:00 2001 From: Maxim Ganetsky Date: Fri, 18 Feb 2022 01:00:39 +0300 Subject: [PATCH] Cocoa: TCocoaContext.GetTextExtentPoint() height correction (its height now matches the font text extents), patch by David Jenkins, issue #39649 --- lcl/interfaces/cocoa/cocoagdiobjects.pas | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lcl/interfaces/cocoa/cocoagdiobjects.pas b/lcl/interfaces/cocoa/cocoagdiobjects.pas index 05b756e05e..b48c23a1b3 100644 --- a/lcl/interfaces/cocoa/cocoagdiobjects.pas +++ b/lcl/interfaces/cocoa/cocoagdiobjects.pas @@ -2198,7 +2198,7 @@ var s : NSString; AttribStr : CFAttributedStringRef; CoreLine : CTLineRef; - r : NSRect; + height, width, asc, dsc, lead: CGFloat; begin S := NSStringUtf8(AStr, ACount); @@ -2214,9 +2214,10 @@ begin begin CoreLine := CTLineCreateWithAttributedString(CFAttributedStringRef(AttribStr)); try - r := CTLineGetBoundsWithOptions(CoreLine, 0); - Size.cx := Round(r.size.width); - Size.cy := Round(r.Size.height); + width := CTLineGetTypographicBounds(CoreLine, @asc, @dsc, @lead); + height := asc + abs(dsc) + lead; + Size.cx := Round(width); + Size.cy := Round(height); finally CFRelease(CoreLine); end;