判断TrueType字体

function IsTrueTypeFont(FontName : string) : boolean;
const
  PITCH_MASK: byte = $0F;  
var
  TxMetric: TTextMetric;
  TempCanvas : TCanvas;
  PitchTest : byte;
begin
  TempCanvas := TCanvas.Create;
  TempCanvas.Handle := CreateCompatibleDC(0));
  TempCanvas.Font.Name := FontName;
  GetTextMetrics(TempCanvas.Handle, TxMetric);
     PitchTest := TxMetric.tmPitchAndFamily and PITCH_MASK;
  Result := ((PitchTest and TMPF_TRUETYPE) <> 0));
  TempCanvas.free;
end;
/////////////////////////////////////
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;

上一篇:Eclipse安装hibernate插件


下一篇:文件读取ndarry 等价于DataFrame的操作