Printers, implements printer.fonts (windows), issue #17122

git-svn-id: trunk@43184 -
This commit is contained in:
jesus 2013-10-09 04:36:52 +00:00
parent 354c863fdb
commit e0905893f5
3 changed files with 35 additions and 1 deletions

View File

@ -1169,6 +1169,37 @@ begin
end;
end;
function PrinterEnumFontsProc(
var ELogFont: LCLType.TEnumLogFontEx;
var Metric: LCLType.TNewTextMetricEx;
FontType: Longint;
Data:LParam):Longint; stdcall;
var
S: string;
Lst: TStrings;
begin
s := StrPas(ELogFont.elfLogFont.lfFaceName);
Lst := TStrings(PtrInt(Data));
if Lst.IndexOf(S)<0 then
Lst.AddObject(S, TObject(PtrInt(FontType)));
result := 1;
end;
procedure TWinPrinter.DoEnumFonts(Lst: TStrings);
var
Lf: TLogFont;
begin
if (Lst=nil) then
exit;
Lst.Clear;
if Printers.Count>0 then begin
Lf.lfFaceName := '';
Lf.lfCharSet := DEFAULT_CHARSET;
Lf.lfPitchAndFamily := 0;
LCLIntf.EnumFontFamiliesEx(Canvas.Handle, @Lf, @PrinterEnumFontsProc, PtrInt(Lst), 0);
end;
end;
initialization
Printer:=TWinPrinter.Create;

View File

@ -60,6 +60,7 @@ Type
function DoGetDefaultBinName: string; override;
function DoGetBinName: string; override;
procedure DoSetBinName(aName: string); override;
procedure DoEnumFonts(Lst: TStrings); override;
function DoSetPrinter(aName : string): Integer; override;

View File

@ -717,6 +717,7 @@ begin
else
raise EPrinter.Create('Printer index out of range!');
SetPrinter(aName);
DoResetFontsList;
end
else
raise EPrinter.Create('No printers defined!');
@ -772,7 +773,8 @@ end;
procedure TPrinter.DoResetFontsList;
begin
//Override this method
if fFonts<>nil then
fFonts.Clear;
end;
//Initialize the Lst with all definied printers