cocoa: Fixes bug #31959: in FontDialog selected bold, result shows none style

git-svn-id: trunk@55326 -
This commit is contained in:
sekelsenmat 2017-06-12 08:35:37 +00:00
parent 1afa4599a9
commit 618c809be9
3 changed files with 16 additions and 3 deletions

View File

@ -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;

View File

@ -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

View File

@ -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;