carbon: fix for TCarbonControl.SetFont function and non-standard fonts

git-svn-id: trunk@22706 -
This commit is contained in:
dmitry 2009-11-22 17:03:54 +00:00
parent 4d3c959a7b
commit 360d8d8008
2 changed files with 22 additions and 3 deletions

View File

@ -822,7 +822,7 @@ end;
procedure TCarbonControl.SetFont(const AFont: TFont);
var
FontStyle: ControlFontStyleRec;
ID: ATSUFontID;
ID: FontFamilyID;
const
SName = 'SetFont';
begin
@ -830,8 +830,8 @@ begin
OSError(GetControlData(ControlRef(Widget), kControlEntireControl,
kControlFontStyleTag, SizeOf(FontStyle), @FontStyle, nil), Self, SName,
SGetData, SControlFont);
ID := FindCarbonFontID(AFont.Name);
if not FindQDFontFamilyID(AFont.Name, ID) then ID:=0;
FontStyle.flags := FontStyle.flags or kControlUseFontMask or kControlUseSizeMask or
kControlUseFaceMask or kControlUseForeColorMask;

View File

@ -71,6 +71,7 @@ function ShiftStateToModifiers(const Shift: TShiftState): Byte;
function FindCarbonFontID(const FontName: String): ATSUFontID;
function CarbonFontIDToFontName(ID: ATSUFontID): String;
function FindQDFontFamilyID(const FontName: String; var Family: FontFamilyID): Boolean;
function FontStyleToQDStyle(const AStyle: TFontStyles): MacOSAll.Style;
function QDStyleToFontStyle(QDStyle: Integer): TFontStyles;
@ -528,6 +529,24 @@ begin
Result := FontName;
end;
{------------------------------------------------------------------------------
Name: CarbonFontIDToFontName
Params: FontName - The font name, UTF-8 encoded
Returns: Returns QuickDraw font family ID
The function returns true, if the font family has be found, false
otherwise.
Note: FMGetFontFamilyFromName is deprecated in OSX 10.4.
There's no replacment for the function, in future OSX versions.
------------------------------------------------------------------------------}
function FindQDFontFamilyID(const FontName: String; var Family: FontFamilyID): Boolean;
var
name : Str255;
begin
name:=FontName;
Family:=FMGetFontFamilyFromName(name);
Result:=true;
end;
{------------------------------------------------------------------------------
Name: FontStyleToQDStyle
Params: AStyle - Font style