Fonts 将Wix字体安装到本地字体文件夹

Fonts 将Wix字体安装到本地字体文件夹,fonts,wix,Fonts,Wix,我正在使用Wix为网站创建安装 添加字体时,WiX会选择.ttf扩展名,并要求您将其安装到本地字体文件夹中(使用目录Id=“FontsFolder”和TrueType=“yes”)。如果删除这些属性,它将被覆盖 有没有办法让WiX毫无怨言地将字体安装到自定义文件夹(../Content/fonts/)中 编辑: 使用上面的代码,我得到了错误: 错误LGHT1076:ICE60:文件font.ttf不是字体,其版本不是附带文件引用。它应该在“语言”列中指定一种语言。 <Directory

我正在使用Wix为网站创建安装

添加字体时,WiX会选择.ttf扩展名,并要求您将其安装到本地字体文件夹中(使用目录Id=“FontsFolder”和TrueType=“yes”)。如果删除这些属性,它将被覆盖

有没有办法让WiX毫无怨言地将字体安装到自定义文件夹(../Content/fonts/)中

编辑:


使用上面的代码,我得到了错误:

错误LGHT1076:ICE60:文件font.ttf不是字体,其版本不是附带文件引用。它应该在“语言”列中指定一种语言。


<Directory Id="WixWorkshop" Name="WixWorkshop">
  <Component Id="Component1" Guid="DE1705EF-B96A-4746-AA9F-2C9D598E7D08">
    <File Id="File1" Name="arial.ttf" Source="arial.ttf" KeyPath="yes"/>
  </Component>
</Directory>

工作正常-任何组件都应参考目录

在问题提出几个月后,我们设法找到了问题:

关键路径解决方案是答案的一半(参见Alex的答案)。如果不在WiX中使用KeyPath属性,下面的解决方案将无法工作

另一部分是WiX在打包MSI时通过链接器(light.exe)运行的内部一致性计算器(ICE)。ICE规则ICE07检查文件的内容,如果它确定文件是字体,将强制文件使用Windows/Fonts

要停止这种情况,需要在light.exe运行时禁用此规则。为此,请在light.exe之后添加-sice:参数。我们的例子是:

light.exe -sice:ICE07

您可以通过添加更多-sice参数来禁用多个规则。

您可以通过VS实现同样的效果:

在安装项目上单击鼠标右键,然后单击“属性”

选择“工具设置”选项卡

在ICE验证部分中,您可以取消显示所有警告,或者在这种情况下取消显示特定的ICEXX警告

[ICE60]

在同一选项卡(工具设置)上,可以向编译器或链接器添加其他参数。因此,在链接器部分只需添加


[-sice:ICE60]

对于引导字形图标\u半身人的特定情况。ttf字体通过设计放入网站的字体文件夹此解决方案可工作,无需取消ICE07警告:

因为您还将同时安装匹配的woff、eot和svg webfonts,所以您可以指定TTF文件有一个配套文件,而不是TrueType字体

如果您天真地只是创建一个WiX片段,将半身人字体文件添加到您的站点字体文件夹中,如下所示:(根据需要替换部分guid)


它会将文件添加到正确的位置,但构建解决方案将产生一个ICE07验证警告,哀叹TTF字体文件必须放在Windows字体文件夹中

考虑到这是一种网络字体,不应该出现在那里,这很烦人,但谢天谢地,因为这是一种网络字体,你需要它以多种格式满足IE、Edge、Chrome、Firefox等的需要。。。这意味着您可以利用非TTF字体变体的存在来消除警告

像这样重构片段:

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
    <Fragment>
        <DirectoryRef Id="WebsiteFontsDir">
            <Component Id="CMP_WebsiteFonts" Guid="{********-482C-4924-B06E-9FAC34F89D1D}" KeyPath="yes">
                <File Id="glyphicons_halflings_regular.eot" Source="$(var.AZViewerModule.TargetDir)fonts\glyphicons-halflings-regular.eot" />
                <File Id="glyphicons_halflings_regular.svg" Source="$(var.AZViewerModule.TargetDir)fonts\glyphicons-halflings-regular.svg" />
                <File Id="glyphicons_halflings_regular.woff" Source="$(var.AZViewerModule.TargetDir)fonts\glyphicons-halflings-regular.woff" />
            </Component>
            <Component Id="CMP_WebsiteFonts2" Guid="{********-BFFE-441D-B8F4-156DD596B09F}">
                <File Id="glyphicons_halflings_regular.ttf" 
                  Source="$(var.ViewerModule.TargetDir)fonts\glyphicons-halflings-regular.ttf" 
                  TrueType="no" 
                  KeyPath="no"
                  CompanionFile="glyphicons_halflings_regular.eot"/>
            </Component>
        </DirectoryRef>
    </Fragment>
</Wix>


在这里,我们拒绝使用TTF字体,并为其提供一个附带文件,该文件是其他web字体文件之一。一切都安装在您期望的位置,并且没有生成ICE07。

KeyPath似乎不起作用。我已将我的代码附加到问题和收到的错误消息中。我对.DLL文件也有同样的问题;禁用ICE07并没有改变任何事情,但禁用ICE60停止了警告。我喜欢这样,因为它不需要禁用警告。非常感谢。
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
    <Fragment>
        <DirectoryRef Id="WebsiteFontsDir">
            <Component Id="CMP_WebsiteFonts" Guid="{********-482C-4924-B06E-9FAC34F89D1D}" KeyPath="yes">
                <File Id="glyphicons_halflings_regular.eot" Source="$(var.ViewerModule.TargetDir)Police\fonts\glyphicons-halflings-regular.eot" />
                <File Id="glyphicons_halflings_regular.svg" Source="$(var.ViewerModule.TargetDir)Police\fonts\glyphicons-halflings-regular.svg" />
                <File Id="glyphicons_halflings_regular.woff" Source="$(var.ViewerModule.TargetDir)Police\fonts\glyphicons-halflings-regular.woff" />
            </Component>
            <Component Id="CMP_WebsiteFonts2" Guid="{********-BFFE-441D-B8F4-156DD596B09F}" KeyPath="yes">
                <File Id="glyphicons_halflings_regular.ttf" Source="$(var.ViewerModule.TargetDir)Police\fonts\glyphicons-halflings-regular.ttf" DefaultVersion="1.001" TrueType="yes" />
            </Component>
     </DirectoryRef>
</Fragment>
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
    <Fragment>
        <DirectoryRef Id="WebsiteFontsDir">
            <Component Id="CMP_WebsiteFonts" Guid="{********-482C-4924-B06E-9FAC34F89D1D}" KeyPath="yes">
                <File Id="glyphicons_halflings_regular.eot" Source="$(var.AZViewerModule.TargetDir)fonts\glyphicons-halflings-regular.eot" />
                <File Id="glyphicons_halflings_regular.svg" Source="$(var.AZViewerModule.TargetDir)fonts\glyphicons-halflings-regular.svg" />
                <File Id="glyphicons_halflings_regular.woff" Source="$(var.AZViewerModule.TargetDir)fonts\glyphicons-halflings-regular.woff" />
            </Component>
            <Component Id="CMP_WebsiteFonts2" Guid="{********-BFFE-441D-B8F4-156DD596B09F}">
                <File Id="glyphicons_halflings_regular.ttf" 
                  Source="$(var.ViewerModule.TargetDir)fonts\glyphicons-halflings-regular.ttf" 
                  TrueType="no" 
                  KeyPath="no"
                  CompanionFile="glyphicons_halflings_regular.eot"/>
            </Component>
        </DirectoryRef>
    </Fragment>
</Wix>