【问题标题】:Can't delete font from setup files无法从设置文件中删除字体
【发布时间】:2020-11-04 20:42:36
【问题描述】:

我已经通过 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 已在系统中打开。

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

【问题讨论】:

  • 卸载前是否关闭了所有使用该字体的应用程序?也许try to use the scripts here 手动测试卸载? (除非你已经这样做了)。
  • 就是这样!非常感谢!
  • 究竟是什么起作用了?
  • 脚本。这个解释here真的很准确。我使用脚本通过 VBScript 安装字体,就像通过 Windows 安装一样。问题是 Windows 注册表的路径直接指向我的 msi 设置生成的字体文件。所以我无法删除已安装的文件,因为 Windows 说“字体文件是我的”。使用脚本,它是已安装字体文件的副本。
  • 好的,我在下面快速添加了一个答案。以防它对某人有所帮助(并为我的金鱼记忆忘记它的未来而写这篇文章)。

标签: installation fonts windows-10 wix delete-file


【解决方案1】:

原创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 将注册字体(至少在下游操作系统版本中是这样)。 Google Fonts(用 Google 字体试试:Nosifer - 非常好辨认)。


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

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

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

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

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

【讨论】:

    猜你喜欢
    • 2023-03-25
    • 2011-12-21
    • 1970-01-01
    • 1970-01-01
    • 2017-01-12
    • 2014-02-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多