Getting typeface and Windows name of font that is not installed

拈花ヽ惹草 提交于 2019-12-31 03:09:06

问题


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.


回答1:


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.




回答2:


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;


来源:https://stackoverflow.com/questions/6196286/getting-typeface-and-windows-name-of-font-that-is-not-installed

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!