mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-18 15:09:26 +02:00
cocoa: storing underlying and strikeout with HFONT
(cherry picked from commit ba8d995dab
)
This commit is contained in:
parent
d5b94cf624
commit
a3b873541c
@ -230,9 +230,10 @@ type
|
||||
constructor CreateDefault(AGlobal: Boolean = False);
|
||||
constructor Create(const ALogFont: TLogFont; AFontName: String; AGlobal: Boolean = False); reintroduce; overload;
|
||||
constructor Create(const AFont: NSFont; AGlobal: Boolean = False); overload;
|
||||
constructor Create(const AFont: NSFont; const AExtraStyle: TCocoaFontStyle; AGlobal: Boolean = False); overload;
|
||||
destructor Destroy; override;
|
||||
class function CocoaFontWeightToWin32FontWeight(const CocoaFontWeight: Integer): Integer; static;
|
||||
procedure SetHandle(ANewHandle: NSFont);
|
||||
procedure SetHandle(ANewHandle: NSFont; const AExtraStyle: TCocoaFontStyle = []);
|
||||
property Antialiased: Boolean read FAntialiased;
|
||||
property Font: NSFont read FFont;
|
||||
property Name: String read FName;
|
||||
@ -738,9 +739,15 @@ begin
|
||||
end;
|
||||
|
||||
constructor TCocoaFont.Create(const AFont: NSFont; AGlobal: Boolean = False);
|
||||
begin
|
||||
Create(AFont, [], AGlobal);
|
||||
end;
|
||||
|
||||
constructor TCocoaFont.Create(const AFont: NSFont; const AExtraStyle: TCocoaFontStyle;
|
||||
AGlobal: Boolean = False); overload;
|
||||
begin
|
||||
inherited Create(AGlobal);
|
||||
SetHandle(AFont);
|
||||
SetHandle(AFont, AExtraStyle);
|
||||
end;
|
||||
|
||||
destructor TCocoaFont.Destroy;
|
||||
@ -767,7 +774,7 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCocoaFont.SetHandle(ANewHandle: NSFont);
|
||||
procedure TCocoaFont.SetHandle(ANewHandle: NSFont; const AExtraStyle: TCocoaFontStyle = []);
|
||||
var
|
||||
pool: NSAutoreleasePool;
|
||||
lsymTraits: NSFontSymbolicTraits;
|
||||
@ -788,6 +795,7 @@ begin
|
||||
Include(FStyle, cfs_Bold);
|
||||
if (lsymTraits and NSFontItalicTrait) <> 0 then
|
||||
Include(FStyle, cfs_Italic);
|
||||
FStyle := FStyle + AExtraStyle;
|
||||
|
||||
FAntialiased := True;
|
||||
Pool.release;
|
||||
|
@ -160,6 +160,7 @@ var
|
||||
|
||||
procedure FontToDict(src: TFont; dst: NSMutableDictionary);
|
||||
procedure DictToFont(src: NSDictionary; dst: TFont);
|
||||
function DictToCocoaFontStyle(src: NSDictionary): TCocoaFontStyle;
|
||||
|
||||
implementation
|
||||
|
||||
@ -646,6 +647,24 @@ begin
|
||||
dst.Color := cl;
|
||||
end;
|
||||
|
||||
|
||||
function DictToCocoaFontStyle(src: NSDictionary): TCocoaFontStyle;
|
||||
begin
|
||||
Result := [];
|
||||
if (src = nil) then Exit;
|
||||
|
||||
if ObjToNum( src.objectForKey(NSUnderlineStyleAttributeName), 0) = NSUnderlineStyleNone then
|
||||
Exclude(Result, cfs_Underline)
|
||||
else
|
||||
Include(Result, cfs_Underline);
|
||||
|
||||
if ObjToNum( src.objectForKey(NSStrikethroughStyleAttributeName), 0) = NSUnderlineStyleNone then
|
||||
Exclude(Result, cfs_Strikeout)
|
||||
else
|
||||
Include(Result, cfs_Strikeout);
|
||||
end;
|
||||
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
Method: TCocoaWSFontDialog.ShowModal
|
||||
Params: ACommonDialog - LCL font dialog
|
||||
@ -811,9 +830,9 @@ begin
|
||||
if (FontDialog.Font.PixelsPerInch<>72) and (FontDialog.Font.PixelsPerInch<>0) then
|
||||
newFont := NSFont.fontWithDescriptor_size(newFont.fontDescriptor, newFont.pointSize * FontDialog.Font.PixelsPerInch / 72);
|
||||
|
||||
newHandle := TCocoaFont.Create(newFont);
|
||||
newHandle := TCocoaFont.Create(newFont, DictToCocoaFontStyle( FontAttr ));
|
||||
FontDialog.Font.Handle := HFONT(newHandle);
|
||||
DictToFont( FontAttr, FontDialog.Font);
|
||||
DictToFont( FontAttr, FontDialog.Font );
|
||||
end;
|
||||
|
||||
function TFontPanelDelegate.validModesForFontPanel(afontPanel: NSFontPanel
|
||||
|
Loading…
Reference in New Issue
Block a user