Mega Code Archive

 
Categories / Delphi / Examples
 

True Type Font

Title: True Type Font? Question: True Type Font? Answer: I suppose that all my articles work in Delphi 3.x or higher because i don't have early versions to test. Create a function that returns a boolean value and receive input a FontName and put this code inside. //..... Don't Forget a parameter (FontName: String)... var pitch: Byte MyCanvas: TCanvas; TextMet: TTextMetric; begin Result:=False; MyCanvas:= TCanvas.Create; Try MyCanvas.Handle:= CreateCompatibleDC (0); MyCanvas.Font.Name:=FontName; GetTextMetrics (MyCanvas.Handle, TextMet); Pitch := TextMet.tmPitchAndFamyly and $07; Result:= ((Pitch and TMPF_TRUETYPE)0); finally MyCanvas.Free; end; end;