2006-10-10

无需安装使用 TTF 字体

以下代码演示无需在 Windows 中安装,即可在你的程序中使用 TTF(True Type)字体:
{First load it in the OnCreate event of a form):
procedure TForm1.FormCreate(Sender: TObject) ;
begin
AddFontResource('c:\FONTS\MyFont.TTF') ;
SendMessage(HWND_BROADCAST, WM_FONTCHANGE, 0, 0) ;
end;

{Before application terminates we must free it:}
procedure TForm1.FormClose
(Sender: TObject; var Action: TCloseAction) ;
begin
RemoveFontResource('C:\FONTS\MyFont.TTF') ;
SendMessage(HWND_BROADCAST, WM_FONTCHANGE, 0, 0) ;
end;
原文名称:Use TTF without Installing
原文地址:http://delphi.about.com/cs/adptips2000/a/bltip1100_3.htm

没有评论: