Question and Answer Database FAQ1091D.txt — EnumFontFamilies() Category :Printing Platform :All-32Bit Product : Question: How do I use the Windows API callback function EnumFontFamilies()? Answer: The Following example adds the list of fonts and sizes for the current printer to a TMemo component. Example: uses Printers; function EnumFontFamilyProc(var lf : TLogFont; var tm : TNewTextMetric; FontType : integer; var Memo : TMemo) : integer {$IFDEF WIN32} stdcall; {$ELSE} ; export; {$ENDIF} begin Memo.Lines.Add(StrPas(@lf.lfFaceName) + #32 + IntToStr(lf.lfHeight)); result := 1; end; function EnumFontFamiliesProc(var lf : TLogFont; var tm : TNewTextMetric; FontType : integer; var Memo : TMemo) : integer {$IFDEF WIN32} stdcall; {$ELSE} ; export; {$ENDIF} begin if FontType = TRUETYPE_FONTTYPE then begin Memo.Lines.Add(StrPas(@lf.lfFaceName) + #32 + 'All Sizes'); end else EnumFontFamilies(Printer.Handle, @lf.lfFaceName, @EnumFontFamilyProc, LongInt(@Memo)); result := 1; end; procedure TForm1.Button1Click(Sender: TObject); var tm : TTextMetric; i : integer; begin if PrintDialog1.Execute then begin EnumFontFamilies(Printer.Handle, nil, @EnumFontFamiliesProc, LongInt(@Memo1)); end; end; 4/2/99 11:21:46 AM
Last Modified: 01-SEP-99