mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-12 06:56:10 +02:00
cocoa: Fixes bug #31959: in FontDialog selected bold, result shows none style
git-svn-id: trunk@55326 -
This commit is contained in:
parent
1afa4599a9
commit
618c809be9
@ -691,6 +691,7 @@ end;
|
||||
procedure TCocoaFont.SetHandle(ANewHandle: NSFont);
|
||||
var
|
||||
pool: NSAutoreleasePool;
|
||||
lsymTraits: NSFontSymbolicTraits;
|
||||
begin
|
||||
if FFont <> nil then
|
||||
begin
|
||||
@ -701,7 +702,14 @@ begin
|
||||
FFont.retain;
|
||||
FName := NSStringToString(FFont.familyName);
|
||||
FSize := Round(FFont.pointSize);
|
||||
|
||||
FStyle := [];
|
||||
lsymTraits := FFont.fontDescriptor.symbolicTraits;
|
||||
if (lsymTraits and NSFontBoldTrait) <> 0 then
|
||||
Include(FStyle, cfs_Bold);
|
||||
if (lsymTraits and NSFontItalicTrait) <> 0 then
|
||||
Include(FStyle, cfs_Italic);
|
||||
|
||||
FAntialiased := True;
|
||||
Pool.release;
|
||||
end;
|
||||
@ -2185,6 +2193,9 @@ begin
|
||||
|
||||
TM.tmWeight := Font.CocoaFontWeightToWin32FontWeight(NSFontManager.sharedFontManager.weightOfFont(Font.Font));
|
||||
|
||||
if cfs_Bold in Font.Style then
|
||||
TM.tmWeight := Min(FW_BOLD, TM.tmWeight);
|
||||
|
||||
if cfs_Italic in Font.Style then
|
||||
TM.tmItalic := 1;
|
||||
|
||||
|
@ -1256,7 +1256,7 @@ begin
|
||||
Traits := NSFontManager.sharedFontManager.traitsOfFont(AFont.Font);
|
||||
if (Traits and NSFontBoldTrait) <> 0 then
|
||||
ALogFont^.lfWeight := FW_BOLD
|
||||
else;
|
||||
else
|
||||
ALogFont^.lfWeight := FW_NORMAL;
|
||||
if (Traits and NSFontItalicTrait) <> 0 then
|
||||
ALogFont^.lfItalic := 1
|
||||
|
@ -454,10 +454,12 @@ end;
|
||||
procedure TFontPanelDelegate.doSelectFont();
|
||||
var
|
||||
oldHandle, newHandle: TCocoaFont;
|
||||
newFont: NSFont;
|
||||
oldFont, newFont: NSFont;
|
||||
begin
|
||||
oldHandle := TCocoaFont(FontDialog.Font.Handle);
|
||||
newFont := FontPanel.panelConvertFont(oldHandle.Font);
|
||||
oldFont := oldHandle.Font;
|
||||
//oldFont := NSFont.fontWithName_size(NSFont.systemFontOfSize(0).fontDescriptor.postscriptName, 0);
|
||||
newFont := FontPanel.panelConvertFont(oldFont);
|
||||
newHandle := TCocoaFont.Create(newFont);
|
||||
FontDialog.Font.Handle := HFONT(newHandle);
|
||||
end;
|
||||
|
Loading…
Reference in New Issue
Block a user