mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-14 13:19:20 +02:00
carbon: use ThemeSystemFont instead of ATSU font as default font
git-svn-id: trunk@27169 -
This commit is contained in:
parent
bdcfa05b81
commit
b905dfda78
@ -1158,7 +1158,7 @@ end;
|
|||||||
constructor TCarbonFont.Create(AGlobal: Boolean);
|
constructor TCarbonFont.Create(AGlobal: Boolean);
|
||||||
begin
|
begin
|
||||||
inherited Create(AGlobal);
|
inherited Create(AGlobal);
|
||||||
|
|
||||||
FStyle := DefaultTextStyle;
|
FStyle := DefaultTextStyle;
|
||||||
FLineRotation := 0;
|
FLineRotation := 0;
|
||||||
end;
|
end;
|
||||||
@ -1195,6 +1195,7 @@ var
|
|||||||
S: ByteCount;
|
S: ByteCount;
|
||||||
A: ATSUAttributeValuePtr;
|
A: ATSUAttributeValuePtr;
|
||||||
ID: ATSUFontID;
|
ID: ATSUFontID;
|
||||||
|
H: Integer;
|
||||||
const
|
const
|
||||||
SSetAttrs = 'ATSUSetAttributes';
|
SSetAttrs = 'ATSUSetAttributes';
|
||||||
SName = 'CreateStyle';
|
SName = 'CreateStyle';
|
||||||
@ -1216,15 +1217,16 @@ begin
|
|||||||
SSetAttrs, 'kATSUFontTag');
|
SSetAttrs, 'kATSUFontTag');
|
||||||
end;
|
end;
|
||||||
|
|
||||||
if ALogFont.lfHeight <> 0 then
|
if ALogFont.lfHeight = 0
|
||||||
begin
|
then H := CarbonDefaultFontSize
|
||||||
Attr := kATSUSizeTag;
|
else H := ALogFont.lfHeight;
|
||||||
M := Abs(ALogFont.lfHeight) shl 16;
|
|
||||||
A := @M;
|
Attr := kATSUSizeTag;
|
||||||
S := SizeOf(M);
|
M := Abs(ALogFont.lfHeight) shl 16;
|
||||||
OSError(ATSUSetAttributes(Result, 1, @Attr, @S, @A), Self, SName,
|
A := @M;
|
||||||
SSetAttrs, 'kATSUSizeTag');
|
S := SizeOf(M);
|
||||||
end;
|
OSError(ATSUSetAttributes(Result, 1, @Attr, @S, @A), Self, SName,
|
||||||
|
SSetAttrs, 'kATSUSizeTag');
|
||||||
|
|
||||||
if ALogFont.lfWeight > FW_NORMAL then
|
if ALogFont.lfWeight > FW_NORMAL then
|
||||||
begin
|
begin
|
||||||
|
@ -64,6 +64,10 @@ var
|
|||||||
HIViewClassID: CFStringRef; // class CFString for HIView
|
HIViewClassID: CFStringRef; // class CFString for HIView
|
||||||
CustomControlClassID: CFStringRef; // class CFString for custom control
|
CustomControlClassID: CFStringRef; // class CFString for custom control
|
||||||
|
|
||||||
|
var
|
||||||
|
CarbonDefaultFont : AnsiString = '';
|
||||||
|
CarbonDefaultFontSize : Integer = 0;
|
||||||
|
|
||||||
{$I mackeycodes.inc}
|
{$I mackeycodes.inc}
|
||||||
|
|
||||||
function VirtualKeyCodeToMac(AKey: Word): Word;
|
function VirtualKeyCodeToMac(AKey: Word): Word;
|
||||||
@ -494,13 +498,19 @@ end;
|
|||||||
Returns: Carbon font ID of font with the specified name
|
Returns: Carbon font ID of font with the specified name
|
||||||
------------------------------------------------------------------------------}
|
------------------------------------------------------------------------------}
|
||||||
function FindCarbonFontID(const FontName: String): ATSUFontID;
|
function FindCarbonFontID(const FontName: String): ATSUFontID;
|
||||||
|
var
|
||||||
|
fn : String;
|
||||||
begin
|
begin
|
||||||
Result := 0;
|
Result := 0;
|
||||||
|
|
||||||
//DebugLn('FindCarbonFontID ' + FontName);
|
//DebugLn('FindCarbonFontID ' + FontName);
|
||||||
if (FontName <> '') and not SameText(FontName, 'default') then
|
|
||||||
|
if SameText(FontName, 'default')
|
||||||
|
then fn:=CarbonDefaultFont
|
||||||
|
else fn:=FontName;
|
||||||
|
if (FontName <> '') then
|
||||||
begin
|
begin
|
||||||
OSError(ATSUFindFontFromName(@FontName[1], Length(FontName),
|
OSError(ATSUFindFontFromName(@fn[1], Length(fn),
|
||||||
kFontFullName, kFontMacintoshPlatform, kFontRomanScript,
|
kFontFullName, kFontMacintoshPlatform, kFontRomanScript,
|
||||||
kFontEnglishLanguage, Result),
|
kFontEnglishLanguage, Result),
|
||||||
'FindCarbonFontID', 'ATSUFindFontFromName');
|
'FindCarbonFontID', 'ATSUFindFontFromName');
|
||||||
@ -1317,6 +1327,18 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure InitDefaultFont;
|
||||||
|
var
|
||||||
|
s : Str255;
|
||||||
|
st : MacOSAll.Style;
|
||||||
|
sz : SInt16;
|
||||||
|
begin
|
||||||
|
//Note: the GetThemeFont is deprecated in 10.5. CoreText functions should be used!
|
||||||
|
MacOSAll.GetThemeFont(kThemeSystemFont, GetApplicationScript, @s, sz, st);
|
||||||
|
CarbonDefaultFont := s;
|
||||||
|
CarbonDefaultFontSize := sz;
|
||||||
|
end;
|
||||||
|
|
||||||
var
|
var
|
||||||
EventSpec: Array [0..8] of EventTypeSpec;
|
EventSpec: Array [0..8] of EventTypeSpec;
|
||||||
CustomControlHandlerUPP: EventHandlerUPP;
|
CustomControlHandlerUPP: EventHandlerUPP;
|
||||||
@ -1357,6 +1379,8 @@ initialization
|
|||||||
CustomControlHandlerUPP, Length(EventSpec), @EventSpec[0], nil, nil),
|
CustomControlHandlerUPP, Length(EventSpec), @EventSpec[0], nil, nil),
|
||||||
'CarbonProc.initialization', 'HIObjectRegisterSubclass');
|
'CarbonProc.initialization', 'HIObjectRegisterSubclass');
|
||||||
|
|
||||||
|
InitDefaultFont;
|
||||||
|
|
||||||
finalization
|
finalization
|
||||||
|
|
||||||
FreeCFString(CustomControlClassID);
|
FreeCFString(CustomControlClassID);
|
||||||
|
Loading…
Reference in New Issue
Block a user