您应该枚举系统中的所有字体:
procedure TPDFFontMapper.EnumFonts;
var
LF: TLogFont;
begin
System.FillChar(LF, sizeof(LF), 0);
LF.lfCharSet := DEFAULT_CHARSET;
FDC := CreateCompatibleDC(0);
try
Windows.EnumFontFamiliesEx(FDC, LF, @EnumFFProc, Integer(Self), 0);
finally
Windows.DeleteDC(FDC);
end;
end;
您应该有一个为每个字体调用的函数,并测试它是否是矢量字体(TrueType和OpenType字体都被视为TrueType字体):
function EnumFFProc(const LogFont: TEnumLogFontEx; const TextMetric: TNewTextMetric; FontType: DWORD; LParam: DWORD): Integer; stdcall;
begin
if FontType and TRUETYPE_FONTTYPE = TRUETYPE_FONTTYPE then
// do sometghing useful with the logfont...
Result := 1;
end;