Author: Tomas Rutkauskas How to tell if a selected font is a True Type font Answer: Solve 1: 1 uses 2 SysUtils, WinTypes, Classes, Forms, Dialogs, StdCtrls, Controls; 3 4 function isTrueType(FontName: string): Boolean; 5 procedure Button1Click(Sender: TObject); 6 7 procedure TForm1.Button1Click(Sender: TObject); 8 begin 9 if isTrueType('Courier') then 10 showmessage('Is a true type font') 11 else 12 showmessage('Not true type'); 13 end; 14 15 function EnumFontFamProc(var LogFont: TLogFont; var TextMetric: TTextMetric; 16 FontType: Integer; TF: TForm1): Integer; export; stdcall; 17 begin 18 Result := 1; 19 if FontType and TRUETYPE_FONTTYPE > 0 then 20 Result := 0; {stop enumerating} 21 end; 22 23 function TForm1.isTrueType(FontName: string): Boolean; 24 var 25 Buffer: array[0..255] of Char; 26 begin 27 StrPCopy(Buffer, FontName); 28 result := (EnumFontFamilies(Canvas.Handle, Buffer, @EnumFontFamProc, 29 LongInt(Self)) = false); 30 end; Solve 2: 31 function IsTrueType(const FaceName: string): Boolean; 32 var 33 Canvas: TCanvas; 34 DC: THandle; 35 TextMetric: TTextMetric; 36 begin 37 Canvas := TCanvas.Create; 38 try 39 DC := GetDC(GetDesktopWindow); 40 try 41 Canvas.Handle := DC; 42 Canvas.Font.Name := FaceName; 43 GetTextMetrics(Canvas.Handle, TextMetric); 44 Result := (TextMetric.tmPitchAndFamily and TMPF_TRUETYPE) <> 0; 45 finally 46 ReleaseDC(GetDesktopWindow, DC); 47 end; 48 finally 49 Canvas.Free; 50 end; 51 end;