判断TrueType字体

  • 主题发起人 主题发起人 import
  • 开始时间 开始时间
I

import

Unregistered / Unconfirmed
GUEST, unregistred user!
判断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;
判断是否有TrueType字体
function IsTrueTypeAvailable : bool;
var
{$IFDEF WIN32}
rs : TRasterizerStatus;
{$ELSE}
rs : TRasterizer_Status;
{$ENDIF}
begin
result := false;
if not GetRasterizerCaps(rs, sizeof(rs)) then exit;
if rs.WFlags and TT_AVAILABLE <> TT_AVAILABLE then exit;
if rs.WFlags and TT_ENABLED <> TT_ENABLED then exit;
result := true;
end;
 

Similar threads

后退
顶部