From 038a93c1fdc9293fa6cb3fd45931bd45cd488df6 Mon Sep 17 00:00:00 2001 From: David Jenkins Date: Thu, 24 Oct 2024 00:36:38 +0000 Subject: [PATCH] Cocoa: Add version of TCocoaContext.TextOut() with float instead of Integer position params --- lcl/interfaces/cocoa/cocoagdiobjects.pas | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lcl/interfaces/cocoa/cocoagdiobjects.pas b/lcl/interfaces/cocoa/cocoagdiobjects.pas index d9b13a62b3..c9eec9c539 100644 --- a/lcl/interfaces/cocoa/cocoagdiobjects.pas +++ b/lcl/interfaces/cocoa/cocoagdiobjects.pas @@ -410,6 +410,7 @@ type procedure BackgroundFill(dirtyRect:NSRect); procedure Ellipse(X1, Y1, X2, Y2: Integer); procedure TextOut(X, Y: Integer; Options: Longint; Rect: PRect; UTF8Chars: PChar; Count: Integer; CharsDelta: PInteger); + procedure TextOut(X, Y: CGFloat; Options: Longint; Rect: PRect; UTF8Chars: PChar; Count: Integer; CharsDelta: CGFloatPtr); procedure DrawEdge(var Rect: TRect; edge: Cardinal; grfFlags: Cardinal); procedure Frame(const R: TRect); procedure Frame3dClassic(var ARect: TRect; const FrameWidth: integer; const Style: TBevelCut); @@ -1789,6 +1790,21 @@ begin end; procedure TCocoaContext.TextOut(X, Y: Integer; Options: Longint; Rect: PRect; UTF8Chars: PChar; Count: Integer; CharsDelta: PInteger); +var + CharsDeltaFloat: Array of CGFloat; + i: integer; +begin + if CharsDelta <> nil then begin + SetLength(CharsDeltaFloat, Count); + for i := 0 to Count - 1 do + CharsDeltaFloat[i] := CharsDelta[i]; + TextOut(X,Y,Options, Rect, UTF8Chars, Count, @CharsDeltaFloat[0]); + end + else + TextOut(X,Y,Options, Rect, UTF8Chars, Count, CGFloatPtr(nil)); +end; + +procedure TCocoaContext.TextOut(X, Y: CGFloat; Options: Longint; Rect: PRect; UTF8Chars: PChar; Count: Integer; CharsDelta: CGFloatPtr); const UnderlineStyle = NSUnderlineStyleSingle or NSUnderlinePatternSolid; var