mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-08 04:58:11 +02:00
Cocoa: TCocoaContext.GetTextExtentPoint() height correction (its height now matches the font text extents), patch by David Jenkins, issue #39649
(cherry picked from commit ddb029aa77
)
This commit is contained in:
parent
0f862d1634
commit
f6f7c2153a
@ -2206,7 +2206,7 @@ var
|
||||
s : NSString;
|
||||
AttribStr : CFAttributedStringRef;
|
||||
CoreLine : CTLineRef;
|
||||
r : NSRect;
|
||||
height, width, asc, dsc, lead: CGFloat;
|
||||
begin
|
||||
S := NSStringUtf8(AStr, ACount);
|
||||
|
||||
@ -2222,9 +2222,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;
|
||||
|
Loading…
Reference in New Issue
Block a user