开发者

Getting typeface and Windows name of font that is not installed

Can someone tell me how can I get the typeface name of a font? And how can I take the Windows name of the font having the typeface name?

Like开发者_如何学运维 "arialblackno1.ttf" that have typeface "arialblack".

but I am looking to get the typeface name of a font that isn't installed, it is just in a folder.


You say in a comment that you need the name of a font that isn't installed in Windows.

There are two ways of doing this that I can think of:-

  • Use FreeType

  • Or, use GDI+, and PrivateFontCollection.AddFontFile()

Either way, you will need to find Delphi wrappers for these libraries. Google should help.

There seems to be a FreeType binding as part of AggPas. It's not something I've tried, though.


Actually, i have a little idea about what exactly are you asking (terms!)

procedure TForm14.FormCreate(Sender: TObject);
var
  DC: HDC;
  Font: HFONT;
  LogFont: TLogFont;
begin
  DC := GetDC(HWND_DESKTOP);
  Win32Check(DC <> 0);
  Font := GetCurrentObject(DC, OBJ_FONT);
  Win32Check(Font <> 0);
  Win32Check(GetObject(Font, SizeOf(LogFont), @LogFont) > 0);
  ShowMessage(LogFont.lfFaceName);
  Win32Check(ReleaseDC(HWND_DESKTOP, DC) = 1);
end;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜