mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-16 02:39:15 +02:00
Merged revision(s) 51983 #7ccb2f58d2 from trunk:
Win32: first attempt to implement TWin32WidgetSet.FontIsMonoSpace. Issue #0028898. ........ git-svn-id: branches/fixes_1_6@51996 -
This commit is contained in:
parent
7c789e1ef4
commit
304a191c25
@ -103,6 +103,54 @@ begin
|
|||||||
Result := True;
|
Result := True;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function EnumFontsCallBack(
|
||||||
|
var LogFont: TEnumLogFontEx;
|
||||||
|
var Metric: TNewTextMetricEx;
|
||||||
|
FontType: Longint;
|
||||||
|
Data: LParam):LongInt; stdcall;
|
||||||
|
var
|
||||||
|
L: TStringList;
|
||||||
|
S: String;
|
||||||
|
begin
|
||||||
|
L := TStringList(PtrInt(Data));
|
||||||
|
S := LogFont.elfLogFont.lfFaceName;
|
||||||
|
if ((logfont.elfLogFont.lfPitchAndFamily and FIXED_PITCH) = FIXED_PITCH) then
|
||||||
|
begin
|
||||||
|
L.Add(S);
|
||||||
|
end;
|
||||||
|
result := 1;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
function TWin32WidgetSet.FontIsMonoSpace(Font: HFont): boolean;
|
||||||
|
var
|
||||||
|
LF: LogFontA;
|
||||||
|
Res: LongInt;
|
||||||
|
List: TStringList;
|
||||||
|
FontName: String;
|
||||||
|
DC: HDC;
|
||||||
|
begin
|
||||||
|
Result := False;
|
||||||
|
FillChar(LF{%H-}, SizeOf(LogFontA), #0);
|
||||||
|
Res := GetObject(Font, SizeOf(LogFontA),@LF);
|
||||||
|
//writeln('TWin32WidgetSet.FontIsMonoSpace: Res = ',Res,' SizeOf(LogFont) = ',SizeOf(LogFontA));
|
||||||
|
//TWin32WidgetSet.GetObject uses LogFontW and converts back to LogFontA, so Res should be SizeOf(LogFontW)
|
||||||
|
if (Res <> SizeOf(LogFontW)) then
|
||||||
|
Exit;
|
||||||
|
LF.lfCharSet := DEFAULT_CHARSET;
|
||||||
|
LF.lfPitchAndFamily := 0;
|
||||||
|
FontName := LF.lfFaceName;
|
||||||
|
DC := GetDC(0);
|
||||||
|
List := TStringList.Create;
|
||||||
|
try
|
||||||
|
EnumFontFamiliesEX(DC, @LF, @EnumFontsCallback, PtrInt(List), 0);
|
||||||
|
Result := (List.IndexOf(FontName) > -1);
|
||||||
|
finally
|
||||||
|
ReleaseDC(0, DC);
|
||||||
|
List.Free;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TWin32WidgetSet.HandleProcessEvent(AData: PtrInt; AFlags: dword);
|
procedure TWin32WidgetSet.HandleProcessEvent(AData: PtrInt; AFlags: dword);
|
||||||
var
|
var
|
||||||
lProcessEvent: PProcessEvent absolute AData;
|
lProcessEvent: PProcessEvent absolute AData;
|
||||||
|
@ -44,6 +44,7 @@ function ExtUTF8Out(DC: HDC; X, Y: Integer; Options: Longint; Rect: PRect;
|
|||||||
Str: PChar; Count: Longint; Dx: PInteger): Boolean; override;
|
Str: PChar; Count: Longint; Dx: PInteger): Boolean; override;
|
||||||
|
|
||||||
function FontCanUTF8({%H-}Font: HFont): boolean; override;
|
function FontCanUTF8({%H-}Font: HFont): boolean; override;
|
||||||
|
function FontIsMonoSpace(Font: HFont): boolean; override;
|
||||||
|
|
||||||
function GetAcceleratorString(const AVKey: Byte; const AShiftState: TShiftState): String; override;
|
function GetAcceleratorString(const AVKey: Byte; const AShiftState: TShiftState): String; override;
|
||||||
function GetControlConstraints(Constraints: TObject): boolean; override;
|
function GetControlConstraints(Constraints: TObject): boolean; override;
|
||||||
|
Loading…
Reference in New Issue
Block a user