procedure TForm1.FormCreate(Sender: TObject);
begin
  AddFontResource(PChar(ExtractFilePath(ParamStr(0) + 'YourFont.TTF')));
  SendMessage(HWND_BROADCAST, WM_FONTCHANGE, 0, 0);
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
  RemoveFontResource(PChar(ExtractFilePath(ParamStr(0) + 'YourFont.TTF')));
  SendMessage(HWND_BROADCAST, WM_FONTCHANGE, 0, 0);
end;
以上是程序使用系统中未安装的字体的方法(不安装到系统中),
我试过以上方法,不能用,程序并未使用新安装的字体.
问题:如何让程序使用新的字体或把字体文件安装到XP和WIN系统中?

解决方案 »

  1.   

    XP系统下,只要把字体文件copy 到 windows\fonts下即可。
      

  2.   

    手动复制到FONTS文件夹后,字体能正常安装但用DELPHI的copyfile函数到FONTS,字体是不会安装的(复制不过去)
      

  3.   

    我做过一个小程序,用INNO  SETUP 打包安装系统新字体,直接可以用了。
    下面是InnoSetup的脚本; -- Example1.iss --
    ; Demonstrates copying 3 files and creating an icon.; SEE THE DOCUMENTATION FOR DETAILS ON CREATING .ISS SCRIPT FILES![Setup]
    AppName=标签吊牌打印
    AppVersion=Ver 1.0
    DefaultDirName=D:\标签吊牌打印
    ;DefaultDirName={pf}\标签吊牌打印系统
    DefaultGroupName=标签吊牌打印
    UninstallDisplayIcon={app}\project1.exe
    Compression=lzma2
    SolidCompression=yes
    OutputDir=setup[Files]
    Source: "project1.exe"; DestDir: "{app}"
    Source: "mydata.mdb"; DestDir: "{app}"
    Source: "标签1.fr3"; DestDir: "{app}"
    Source: "FZXBSJW.TTF"; DestDir: "{win}\fonts"
    ; Install our DLL to {app} so we can access it at uninstall time
    ; Use "Flags: dontcopy" if you don't need uninstall time access
    ;Source: "MyDll.dll"; DestDir: "{app}"[Icons]
    Name: "{commondesktop}\标签吊牌打印"; Filename: "{app}\project1.exe"
    Name: "{group}\标签吊牌打印"; Filename: "{app}\project1.exe"
    Name: {group}\{cm:UninstallProgram,标签吊牌打印}; Filename: {uninstallexe}
      

  4.   

    看看CreateScalableFontResource的用法
    http://bbs.csdn.net/topics/70266268