问题
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