mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-12 18:39:52 +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);
|
procedure TCocoaFont.SetHandle(ANewHandle: NSFont);
|
||||||
var
|
var
|
||||||
pool: NSAutoreleasePool;
|
pool: NSAutoreleasePool;
|
||||||
|
lsymTraits: NSFontSymbolicTraits;
|
||||||
begin
|
begin
|
||||||
if FFont <> nil then
|
if FFont <> nil then
|
||||||
begin
|
begin
|
||||||
@ -701,7 +702,14 @@ begin
|
|||||||
FFont.retain;
|
FFont.retain;
|
||||||
FName := NSStringToString(FFont.familyName);
|
FName := NSStringToString(FFont.familyName);
|
||||||
FSize := Round(FFont.pointSize);
|
FSize := Round(FFont.pointSize);
|
||||||
|
|
||||||
FStyle := [];
|
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;
|
FAntialiased := True;
|
||||||
Pool.release;
|
Pool.release;
|
||||||
end;
|
end;
|
||||||
@ -2185,6 +2193,9 @@ begin
|
|||||||
|
|
||||||
TM.tmWeight := Font.CocoaFontWeightToWin32FontWeight(NSFontManager.sharedFontManager.weightOfFont(Font.Font));
|
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
|
if cfs_Italic in Font.Style then
|
||||||
TM.tmItalic := 1;
|
TM.tmItalic := 1;
|
||||||
|
|
||||||
|
@ -1256,7 +1256,7 @@ begin
|
|||||||
Traits := NSFontManager.sharedFontManager.traitsOfFont(AFont.Font);
|
Traits := NSFontManager.sharedFontManager.traitsOfFont(AFont.Font);
|
||||||
if (Traits and NSFontBoldTrait) <> 0 then
|
if (Traits and NSFontBoldTrait) <> 0 then
|
||||||
ALogFont^.lfWeight := FW_BOLD
|
ALogFont^.lfWeight := FW_BOLD
|
||||||
else;
|
else
|
||||||
ALogFont^.lfWeight := FW_NORMAL;
|
ALogFont^.lfWeight := FW_NORMAL;
|
||||||
if (Traits and NSFontItalicTrait) <> 0 then
|
if (Traits and NSFontItalicTrait) <> 0 then
|
||||||
ALogFont^.lfItalic := 1
|
ALogFont^.lfItalic := 1
|
||||||
|
@ -454,10 +454,12 @@ end;
|
|||||||
procedure TFontPanelDelegate.doSelectFont();
|
procedure TFontPanelDelegate.doSelectFont();
|
||||||
var
|
var
|
||||||
oldHandle, newHandle: TCocoaFont;
|
oldHandle, newHandle: TCocoaFont;
|
||||||
newFont: NSFont;
|
oldFont, newFont: NSFont;
|
||||||
begin
|
begin
|
||||||
oldHandle := TCocoaFont(FontDialog.Font.Handle);
|
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);
|
newHandle := TCocoaFont.Create(newFont);
|
||||||
FontDialog.Font.Handle := HFONT(newHandle);
|
FontDialog.Font.Handle := HFONT(newHandle);
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user