Cocoa: TCocoaContext.GetTextExtentPoint() height correction (its height now matches the font text extents), patch by David Jenkins, issue #39649

This commit is contained in:
Maxim Ganetsky 2022-02-18 01:00:39 +03:00
parent 005bd07b0e
commit ddb029aa77

View File

@ -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;