Fonts 如何使用install4j安装/注册字体

Fonts 如何使用install4j安装/注册字体,fonts,registry,install4j,Fonts,Registry,Install4j,在安装我制作的软件期间,我想在主机(运行Windows)上安装TTF字体。在windows上安装字体意味着两件事: 复制c:\windows\fonts中的TTF文件。这很容易做到 注册字体:更新Windows注册表以更新其字体列表我的问题是:如何使用install4j实现这一点? 提前感谢您的帮助 请参见关于如何以编程方式安装字体的。您可以使用“Run executable”操作来执行前面提到的“fontinst.exe”可执行文件。好吧,我已经用“艰难的方式”完成了,但它可以工作。这是我

在安装我制作的软件期间,我想在主机(运行Windows)上安装TTF字体。在windows上安装字体意味着两件事:

  • 复制c:\windows\fonts中的TTF文件。这很容易做到
  • 注册字体:更新Windows注册表以更新其字体列表我的问题是:如何使用install4j实现这一点?
提前感谢您的帮助

请参见关于如何以编程方式安装字体的。您可以使用“Run executable”操作来执行前面提到的“fontinst.exe”可执行文件。

好吧,我已经用“艰难的方式”完成了,但它可以工作。这是我的密码:

String fontRegKey;
if (Util.isWindows9X())
{ fontRegKey = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Fonts"; }
else
{ fontRegKey = "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Fonts"; }
String [] fontFilesNames = new String[]
    {"braille_tbfr2007_b-2.ttf","BrailleTBFr2007INSHEAb_thermo.ttf","LouisLouis.ttf","LouisLouisThermo.ttf"};
String [] fontNames = new String[]
    {"Braille TBFr2007 INS HEA (TrueType)","Braille TBFr2007 INS HEA thermo (TrueType)",
    "LouisLouis Braille (TrueType)","LouisLouis Braille Thermo (TrueType)"};

for (int i=0 ; i<fontNames.length ; i++)
{
    boolean write = WinRegistry.setValue(RegistryRoot.HKEY_LOCAL_MACHINE, fontRegKey,fontNames[i], fontFilesNames[i]);
}

if (Util.isAtLeastWindowsXP()) //security : delete system font cache
{
    File sd = WinFileSystem.getSystemDirectory();
    File f = new File (sd.getAbsoluteFile()+"\\FNTCACHE.dat") ;
    if (f.exists()) {f.delete();}
}
return true; //mandatory for the script
String-fontRegKey;
如果(Util.isWindows9X())
{fontRegKey=“软件\\Microsoft\\Windows\\CurrentVersion\\Fonts”;}
其他的
{fontRegKey=“软件\\Microsoft\\Windows NT\\CurrentVersion\\Fonts”;}
字符串[]FontFileNames=新字符串[]
{“Brailleetbfr2007_b-2.ttf”、“Brailleetbfr2007insheab_thermo.ttf”、“LouisLouis.ttf”、“LouisLouisThermo.ttf”};
字符串[]fontNames=新字符串[]
{“盲文TBFr2007-INS-HEA(TrueType)”,“盲文TBFr2007-INS-HEA-thermo(TrueType)”,
“路易斯劳伊斯盲文(TrueType)”,“路易斯劳伊斯盲文(TrueType)”;
对于(inti=0;iThanks),还有“registerfont.exe”也有相同的功能。但这两个程序都是旧的,不确定它是否能在win7或Win8下工作。我将尝试一下。