无法从安装文件中删除字体

问题描述

我已经通过WIX构建了一个安装程序,该安装程序将字体HKGrotesk安装在C:/ windows / fonts文件夹中。当我执行安装程序时,一切都很好,并且已经安装了字体。

<Directory Id="..." Name="HK">
  <Component Id="..." Guid="...">
    <File Id="..." Source="(...)\fonts\HK\HKGrotesk-Black.otf" TrueType="yes" />
  </Component>
</DirectoryRef>

问题是当我尝试删除安装文件时。我收到一条消息,说我的HKGrotesk-Black.otf已在系统中打开。

如何进行安装并能够从安装文件文件夹中删除字体文件

解决方法

原始 The below condensed from this answer as source


字体表 :MSI中的Font table用于正确安装字体。在WiX中,您只需指定一些属性as explained here

<DirectoryRef Id="FontsFolder">
  <Component Id="MyFontsFonts" Guid="...">
    <File Id="font1.ttf" Source="font1.ttf" TrueType="yes" />
  </Component>
</DirectoryRef>

Windows资源管理器 :您可以通过Windows资源管理器将字体复制到“字体”文件夹中来注册字体。 Shell将注册字体(至少在下游OS版本中已注册)。 Google Fonts(尝试使用Google字体: Nosifer -非常容易识别)。


脚本 :您可以使用VBScript注册字体:

Set sa = CreateObject("Shell.Application")
Set fonts  = sa.NameSpace(20)
fonts.CopyHere "C:\tmp\SomeFont.ttf"

在PowerShell中(十六进制0x14 = 12月20日):

$sa =  new-object -comobject shell.application
$Fonts =  $sa.NameSpace(0x14)
$Fonts.CopyHere ("C:\tmp\SomeFont.ttf")

具有绝对路径和其他缺陷的傻脚本,但它们应作为示例工作。