diff --git a/lcl/interfaces/cocoa/cocoagdiobjects.pas b/lcl/interfaces/cocoa/cocoagdiobjects.pas index fb4b240a8b..2c5f517901 100644 --- a/lcl/interfaces/cocoa/cocoagdiobjects.pas +++ b/lcl/interfaces/cocoa/cocoagdiobjects.pas @@ -195,7 +195,7 @@ type strict private FFont: NSFont; FName: AnsiString; - FSize: CGFloat; + FSize: Integer; FStyle: TCocoaFontStyle; FAntialiased: Boolean; FIsSystemFont: Boolean; @@ -210,7 +210,7 @@ type property Antialiased: Boolean read FAntialiased; property Font: NSFont read FFont; property Name: String read FName; - property Size: CGFloat read FSize; + property Size: Integer read FSize; property Style: TCocoaFontStyle read FStyle; property RotationDeg: Single read FRotationDeg; end; @@ -559,8 +559,6 @@ var Win32Weight, LoopCount: Integer; CocoaWeight: NSInteger; FTmpFont: NSFont; -const - DPI = 96; // todo: what about Retina displays and scaled displays? begin inherited Create(AGlobal); @@ -580,14 +578,8 @@ begin if ALogFont.lfHeight = 0 then FSize := Round(NSFont.systemFontSize) - else begin - // lfHeight is height in pixels (TFont.ReferenceNeeded), FSize is in points - // (TFont has property "Size" - which is size in points, but it's not passed to LOGFONT) - // todo: check for the actual DPI - // also, negative height and positive height are different hights, thus - // abs() is not really accurate - FSize := Round(Abs(ALogFont.lfHeight * 72 / DPI)*10)/10; - end; + else + FSize := Abs(ALogFont.lfHeight); // create font attributes Win32Weight := ALogFont.lfWeight; diff --git a/lcl/interfaces/cocoa/cocoawinapi.inc b/lcl/interfaces/cocoa/cocoawinapi.inc index d8607edc38..f42e8a233e 100644 --- a/lcl/interfaces/cocoa/cocoawinapi.inc +++ b/lcl/interfaces/cocoa/cocoawinapi.inc @@ -1174,8 +1174,6 @@ var AExtLogPen: PExtLogPen absolute Buf; AFont: TCocoaFont absolute AObject; ALogFont: PLogFont absolute Buf; -const - DPI = 96; begin Result := 0; @@ -1305,7 +1303,7 @@ begin Result := SizeOf(TLogFont); FillChar(ALogFont^, SizeOf(ALogFont^), 0); ALogFont^.lfFaceName := AFont.Name; - ALogFont^.lfHeight := -Round( AFont.Size * DPI / 72); + ALogFont^.lfHeight := AFont.Size; Traits := NSFontManager.sharedFontManager.traitsOfFont(AFont.Font); if (Traits and NSFontBoldTrait) <> 0 then ALogFont^.lfWeight := FW_BOLD