mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-26 05:00:25 +02:00
Cocoa: Add some fixed pitch font checking for the font selector and gdiobjects
This commit is contained in:
parent
309974b57c
commit
1b4edd6f41
@ -351,6 +351,18 @@ type
|
|||||||
procedure setEnabled_(aenabled: ObjCBool); message 'setEnabled:';
|
procedure setEnabled_(aenabled: ObjCBool); message 'setEnabled:';
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
type
|
||||||
|
NSFontWeight = CGFloat;
|
||||||
|
const
|
||||||
|
NSFontWeightRegular = 0.0;
|
||||||
|
|
||||||
|
type
|
||||||
|
NSFontFix = objccategory external (NSFont)
|
||||||
|
// available in 10.15+
|
||||||
|
class function monospacedSystemFontOfSize_weight (fontSize: CGFloat; weight: NSFontWeight): NSFont;
|
||||||
|
message 'monospacedSystemFontOfSize:weight:';
|
||||||
|
end;
|
||||||
|
|
||||||
NSApplicationFix = objccategory external (NSApplication)
|
NSApplicationFix = objccategory external (NSApplication)
|
||||||
{$ifdef BOOLFIX}
|
{$ifdef BOOLFIX}
|
||||||
procedure activateIgnoringOtherApps_(flag: ObjCBool); message 'activateIgnoringOtherApps:';
|
procedure activateIgnoringOtherApps_(flag: ObjCBool); message 'activateIgnoringOtherApps:';
|
||||||
@ -642,6 +654,7 @@ const
|
|||||||
NSAppKitVersionNumber10_13 = 1561;
|
NSAppKitVersionNumber10_13 = 1561;
|
||||||
//NSAppKitVersionNumber10_14 = 1641.10; // Mojave's beta?
|
//NSAppKitVersionNumber10_14 = 1641.10; // Mojave's beta?
|
||||||
NSAppKitVersionNumber10_14 = 1671;
|
NSAppKitVersionNumber10_14 = 1671;
|
||||||
|
NSAppKitVersionNumber10_15 = 1894;
|
||||||
NSAppKitVersionNumber11_0 = 2022; // 2000 starts with beta?
|
NSAppKitVersionNumber11_0 = 2022; // 2000 starts with beta?
|
||||||
NSAppKitVersionNumber12_0 = 2113;
|
NSAppKitVersionNumber12_0 = 2113;
|
||||||
NSAppKitVersionNumber13_0 = 2299;
|
NSAppKitVersionNumber13_0 = 2299;
|
||||||
|
@ -615,6 +615,18 @@ begin
|
|||||||
// If this is not a "systemFont" Create the font ourselves
|
// If this is not a "systemFont" Create the font ourselves
|
||||||
if IsDefault then
|
if IsDefault then
|
||||||
begin
|
begin
|
||||||
|
if ALogFont.lfPitchAndFamily = FIXED_PITCH then
|
||||||
|
begin
|
||||||
|
if NSAppKitVersionNumber >= NSAppKitVersionNumber10_15 then
|
||||||
|
FFont := NSFont.monospacedSystemFontOfSize_weight(FSize, NSFontWeightRegular)
|
||||||
|
else
|
||||||
|
FFont := NSFont.fontWithName_size(NSSTR('Menlo'), FSize);
|
||||||
|
if cfs_Bold in Style then
|
||||||
|
FFont := NSFontManager.sharedFontManager.convertFont_toHaveTrait(FFont, NSBoldFontMask);
|
||||||
|
end
|
||||||
|
else if cfs_Bold in Style then
|
||||||
|
FFont := NSFont.boldSystemFontOfSize( FSize )
|
||||||
|
else
|
||||||
FFont := NSFont.systemFontOfSize( FSize );
|
FFont := NSFont.systemFontOfSize( FSize );
|
||||||
end else begin
|
end else begin
|
||||||
FontName := NSStringUTF8(FName);
|
FontName := NSStringUTF8(FName);
|
||||||
|
@ -1398,6 +1398,8 @@ begin
|
|||||||
ALogFont^.lfFaceName := AFont.Name;
|
ALogFont^.lfFaceName := AFont.Name;
|
||||||
ALogFont^.lfHeight := -AFont.Size; // Cocoa supports only full height (with leading) that corresponds with a negative value in WinAPI
|
ALogFont^.lfHeight := -AFont.Size; // Cocoa supports only full height (with leading) that corresponds with a negative value in WinAPI
|
||||||
Traits := NSFontManager.sharedFontManager.traitsOfFont(AFont.Font);
|
Traits := NSFontManager.sharedFontManager.traitsOfFont(AFont.Font);
|
||||||
|
if AFont.Font.isFixedPitch then
|
||||||
|
ALogFont^.lfPitchAndFamily := FIXED_PITCH;
|
||||||
if (Traits and NSFontBoldTrait) <> 0 then
|
if (Traits and NSFontBoldTrait) <> 0 then
|
||||||
ALogFont^.lfWeight := FW_BOLD
|
ALogFont^.lfWeight := FW_BOLD
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user