mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-15 20:19:24 +02:00
cocoa: switching back to the use of sysetmFont, to prevent an odd vertical offset. #33626
git-svn-id: trunk@58529 -
This commit is contained in:
parent
7a19d55904
commit
0b86f592a2
@ -559,6 +559,7 @@ var
|
|||||||
Win32Weight, LoopCount: Integer;
|
Win32Weight, LoopCount: Integer;
|
||||||
CocoaWeight: NSInteger;
|
CocoaWeight: NSInteger;
|
||||||
FTmpFont: NSFont;
|
FTmpFont: NSFont;
|
||||||
|
IsDefault: Boolean;
|
||||||
begin
|
begin
|
||||||
inherited Create(AGlobal);
|
inherited Create(AGlobal);
|
||||||
|
|
||||||
@ -570,7 +571,18 @@ begin
|
|||||||
// because otherwise the result is wrong in Mac OS X 10.11, see bug 30300
|
// because otherwise the result is wrong in Mac OS X 10.11, see bug 30300
|
||||||
// Code used for 10.10 or inferior:
|
// Code used for 10.10 or inferior:
|
||||||
// FName := NSStringToString(NSFont.systemFontOfSize(0).familyName);
|
// FName := NSStringToString(NSFont.systemFontOfSize(0).familyName);
|
||||||
if IsFontNameDefault(FName) then
|
//
|
||||||
|
// There's a differnet issue with not using systemFont.
|
||||||
|
// NSComboBox, if assigned a manually created font have an odd ascending-offset
|
||||||
|
// (easily seen in Xcode interface builder as well). systemFonts()
|
||||||
|
// don't have such issue at all. see bug 33626
|
||||||
|
// the fix below (detecting "default" font and use systemFont()) is a potential
|
||||||
|
// regression for bug 30300.
|
||||||
|
//
|
||||||
|
// There might font properties (i.e. Transform Matrix) to adjust the position of
|
||||||
|
// the font. But at this time, it's safer to use systemFont() method
|
||||||
|
IsDefault := IsFontNameDefault(FName);
|
||||||
|
if not IsDefault then
|
||||||
begin
|
begin
|
||||||
FTmpFont := NSFont.fontWithName_size(NSFont.systemFontOfSize(0).fontDescriptor.postscriptName, 0);
|
FTmpFont := NSFont.fontWithName_size(NSFont.systemFontOfSize(0).fontDescriptor.postscriptName, 0);
|
||||||
FName := NSStringToString(FTmpFont.familyName);
|
FName := NSStringToString(FTmpFont.familyName);
|
||||||
@ -594,14 +606,14 @@ begin
|
|||||||
include(FStyle, cfs_StrikeOut);
|
include(FStyle, cfs_StrikeOut);
|
||||||
|
|
||||||
// If this is not a "systemFont" Create the font ourselves
|
// If this is not a "systemFont" Create the font ourselves
|
||||||
FontName := NSStringUTF8(FName);
|
if IsDefault then
|
||||||
Attributes := NSDictionary.dictionaryWithObjectsAndKeys(
|
begin
|
||||||
FontName, NSFontFamilyAttribute,
|
FFont := NSFont.systemFontOfSize( FSize );
|
||||||
NSNumber.numberWithFloat(FSize), NSFontSizeAttribute,
|
end else begin
|
||||||
nil);
|
FontName := NSStringUTF8(FName);
|
||||||
FontName.release;
|
FFont := NSFont.fontWithName_size(FontName, FSize);
|
||||||
Descriptor := NSFontDescriptor.fontDescriptorWithFontAttributes(Attributes);
|
FontName.release;
|
||||||
FFont := NSFont.fontWithDescriptor_textTransform(Descriptor, nil);
|
end;
|
||||||
|
|
||||||
if FFont = nil then
|
if FFont = nil then
|
||||||
begin
|
begin
|
||||||
@ -620,7 +632,6 @@ begin
|
|||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// we could use NSFontTraitsAttribute to request the desired font style (Bold/Italic)
|
// we could use NSFontTraitsAttribute to request the desired font style (Bold/Italic)
|
||||||
// but in this case we may get NIL as result. This way is safer.
|
// but in this case we may get NIL as result. This way is safer.
|
||||||
if cfs_Italic in Style then
|
if cfs_Italic in Style then
|
||||||
|
Loading…
Reference in New Issue
Block a user