无法从设置文件中删除字体

Can't delete font from setup files

我已经通过 WIX 构建了一个安装程序,在 C:/windows/fonts 文件夹中安装了 HKGrotesk 字体。当我执行设置时一切正常,字体也已安装。

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

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

我怎样才能让我的安装工作并能够从我的安装文件夹中删除字体文件?

原文: .


字体Table: Font table in an MSI is used to install fonts properly. In WiX you just specify a few attributes as explained here:

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

Windows Explorer: 您可以通过 Windows 将字体复制到字体文件夹中来注册字体探索者。 shell 将注册字体(至少在下游 OS 版本中是这样)。 Google Fonts(尝试使用 Google 字体:Nosifer - 非常容易识别)。


Script: 可以使用VBScript注册字体:

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

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

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

具有绝对路径和其他缺陷的愚蠢脚本,但它们应该可以作为示例使用。