mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-11 18:58:17 +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);
|
||||
begin
|
||||
inherited Create(AGlobal);
|
||||
|
||||
|
||||
FStyle := DefaultTextStyle;
|
||||
FLineRotation := 0;
|
||||
end;
|
||||
@ -1195,6 +1195,7 @@ var
|
||||
S: ByteCount;
|
||||
A: ATSUAttributeValuePtr;
|
||||
ID: ATSUFontID;
|
||||
H: Integer;
|
||||
const
|
||||
SSetAttrs = 'ATSUSetAttributes';
|
||||
SName = 'CreateStyle';
|
||||
@ -1216,15 +1217,16 @@ begin
|
||||
SSetAttrs, 'kATSUFontTag');
|
||||
end;
|
||||
|
||||
if ALogFont.lfHeight <> 0 then
|
||||
begin
|
||||
Attr := kATSUSizeTag;
|
||||
M := Abs(ALogFont.lfHeight) shl 16;
|
||||
A := @M;
|
||||
S := SizeOf(M);
|
||||
OSError(ATSUSetAttributes(Result, 1, @Attr, @S, @A), Self, SName,
|
||||
SSetAttrs, 'kATSUSizeTag');
|
||||
end;
|
||||
if ALogFont.lfHeight = 0
|
||||
then H := CarbonDefaultFontSize
|
||||
else H := ALogFont.lfHeight;
|
||||
|
||||
Attr := kATSUSizeTag;
|
||||
M := Abs(ALogFont.lfHeight) shl 16;
|
||||
A := @M;
|
||||
S := SizeOf(M);
|
||||
OSError(ATSUSetAttributes(Result, 1, @Attr, @S, @A), Self, SName,
|
||||
SSetAttrs, 'kATSUSizeTag');
|
||||
|
||||
if ALogFont.lfWeight > FW_NORMAL then
|
||||
begin
|
||||
|
@ -64,6 +64,10 @@ var
|
||||
HIViewClassID: CFStringRef; // class CFString for HIView
|
||||
CustomControlClassID: CFStringRef; // class CFString for custom control
|
||||
|
||||
var
|
||||
CarbonDefaultFont : AnsiString = '';
|
||||
CarbonDefaultFontSize : Integer = 0;
|
||||
|
||||
{$I mackeycodes.inc}
|
||||
|
||||
function VirtualKeyCodeToMac(AKey: Word): Word;
|
||||
@ -494,13 +498,19 @@ end;
|
||||
Returns: Carbon font ID of font with the specified name
|
||||
------------------------------------------------------------------------------}
|
||||
function FindCarbonFontID(const FontName: String): ATSUFontID;
|
||||
var
|
||||
fn : String;
|
||||
begin
|
||||
Result := 0;
|
||||
|
||||
//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
|
||||
OSError(ATSUFindFontFromName(@FontName[1], Length(FontName),
|
||||
OSError(ATSUFindFontFromName(@fn[1], Length(fn),
|
||||
kFontFullName, kFontMacintoshPlatform, kFontRomanScript,
|
||||
kFontEnglishLanguage, Result),
|
||||
'FindCarbonFontID', 'ATSUFindFontFromName');
|
||||
@ -1317,6 +1327,18 @@ begin
|
||||
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
|
||||
EventSpec: Array [0..8] of EventTypeSpec;
|
||||
CustomControlHandlerUPP: EventHandlerUPP;
|
||||
@ -1357,6 +1379,8 @@ initialization
|
||||
CustomControlHandlerUPP, Length(EventSpec), @EventSpec[0], nil, nil),
|
||||
'CarbonProc.initialization', 'HIObjectRegisterSubclass');
|
||||
|
||||
InitDefaultFont;
|
||||
|
||||
finalization
|
||||
|
||||
FreeCFString(CustomControlClassID);
|
||||
|
Loading…
Reference in New Issue
Block a user