mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-28 16:40:48 +02:00
cocoa: using the name filter for EnumFonts function, issue #39771
This commit is contained in:
parent
f6554ced9b
commit
6f5b2e4b66
@ -48,6 +48,8 @@ function CreateParamsToNSRect(const params: TCreateParams): NSRect;
|
|||||||
|
|
||||||
function NSStringUtf8(s: PChar; len: Integer = -1): NSString;
|
function NSStringUtf8(s: PChar; len: Integer = -1): NSString;
|
||||||
function NSStringUtf8(const s: String): NSString;
|
function NSStringUtf8(const s: String): NSString;
|
||||||
|
function StrToNSString(const s: string; AutoRelease: Boolean = true): NSString;
|
||||||
|
function StrToNSStr(const s: string; AutoRelease: Boolean = true): NSString; inline;
|
||||||
function NSStringToString(ns: NSString): String;
|
function NSStringToString(ns: NSString): String;
|
||||||
|
|
||||||
function GetNSObjectWindow(obj: NSObject): NSWindow;
|
function GetNSObjectWindow(obj: NSObject): NSWindow;
|
||||||
@ -812,6 +814,18 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function StrToNSString(const s: string; AutoRelease: Boolean): NSString;
|
||||||
|
begin
|
||||||
|
Result := NSStringUtf8(s);
|
||||||
|
if Assigned(Result) and AutoRelease then
|
||||||
|
Result := Result.autorelease;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function StrToNSStr(const s: string; AutoRelease: Boolean = true): NSString; inline;
|
||||||
|
begin
|
||||||
|
Result := StrToNSString(s, AutoRelease);
|
||||||
|
end;
|
||||||
|
|
||||||
function NSStringToString(ns: NSString): String;
|
function NSStringToString(ns: NSString): String;
|
||||||
begin
|
begin
|
||||||
Result := CFStringToStr(CFStringRef(ns));
|
Result := CFStringToStr(CFStringRef(ns));
|
||||||
|
@ -735,25 +735,28 @@ var
|
|||||||
w : CGFloat;
|
w : CGFloat;
|
||||||
t : Integer;
|
t : Integer;
|
||||||
|
|
||||||
pitchFilter : Integer;
|
names : NSArray;
|
||||||
|
nameFilter : string;
|
||||||
const
|
const
|
||||||
FW_MAX = FW_HEAVY;
|
FW_MAX = FW_HEAVY;
|
||||||
begin
|
begin
|
||||||
Result := 0;
|
Result := 0;
|
||||||
if not Assigned(Callback) then Exit;
|
if not Assigned(Callback) then Exit;
|
||||||
|
|
||||||
pitchFilter := 0;
|
names := nil;
|
||||||
if Assigned(lpLogFont) then
|
if Assigned(lpLogFont) then
|
||||||
begin
|
begin
|
||||||
pitchFilter := lpLogFont^.lfPitchAndFamily;
|
nameFilter := lpLogFont^.lfFaceName;
|
||||||
if pitchFilter = MONO_FONT then pitchFilter := FIXED_PITCH;
|
if nameFilter<>'' then
|
||||||
if (pitchFilter < 0) or (pitchFilter > VARIABLE_PITCH) then
|
names := NSArray.arrayWithObject( StrToNSStr(nameFilter) );
|
||||||
pitchFilter := 0;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
fm := NSFontManager.sharedFontManager;
|
fm := NSFontManager.sharedFontManager;
|
||||||
for fname in fm.availableFontFamilies do
|
if not Assigned(names) then
|
||||||
|
names := fm.availableFontFamilies;
|
||||||
|
|
||||||
|
for fname in names do
|
||||||
begin
|
begin
|
||||||
try
|
try
|
||||||
FontName := NSStringToString(fname);
|
FontName := NSStringToString(fname);
|
||||||
@ -800,8 +803,6 @@ begin
|
|||||||
else
|
else
|
||||||
ELogFont.elfLogFont.lfPitchAndFamily:=VARIABLE_PITCH;
|
ELogFont.elfLogFont.lfPitchAndFamily:=VARIABLE_PITCH;
|
||||||
|
|
||||||
if (pitchFilter <> 0) and (ELogFont.elfLogFont.lfPitchAndFamily <> pitchFilter) then
|
|
||||||
continue;
|
|
||||||
Result := CallBack(ELogFont, Metric, TRUETYPE_FONTTYPE, lparam);
|
Result := CallBack(ELogFont, Metric, TRUETYPE_FONTTYPE, lparam);
|
||||||
if Result = 0 then Break;
|
if Result = 0 then Break;
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user