How to install Open Type Fonts using Wix

2020-02-06 19:06发布

问题:

I want to install a set of Open Type Fonts as part of my MSI installation. I am using Wix to create the MSI.

Any advice?

回答1:

You need to specify the directory FontsFolder, and set the TrueType attribute on the file:

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


回答2:

I couldn't figure out DirectoryRef—maybe something has changed over the years—but I plopped a Directory in my root TARGETDIR and got it to work. In my case, I needed Arial Narrow Bold on the server:

<Directory Id="TARGETDIR" Name="SourceDir">
   <!-- snip ... all my other stuff here -->
   <Directory Id="FontsFolder">
     <Component Id="ComponentFontArialNarrowBold" Guid="{65F4712A-EAA6-4801-9200-212A3593D6E2}">
       <File Id="FileFontArialNarrowBold" Source="$(var.SolutionDir)Res\Fonts\ARIALNB.TTF" TrueType="yes" KeyPath="yes" />
     </Component>
   </Directory>
</Directory>


回答3:

For install fonts you must set two parts in your codes:

  <Feature Id="ProductFeature" Title="WixSetup" Level="1">
      <ComponentGroupRef Id="ProductComponents" />
      <ComponentRef Id="ApplicationShortcut" />
      <ComponentRef Id="ApplicationShortcutDesktop" />
      <ComponentRef Id="MyFontsFonts" />
  </Feature> 
.
.
.

<Directory Id="TARGETDIR" Name="SourceDir">                  
.
.
.
   <Directory Id="FontsFolder">
        <Component Id="MyFontsFonts" Guid="myGuid">
           <File Id="font1.ttf" Source="Fonts\font1.ttf" TrueType="yes" />
        </Component>
   </Directory>

</Directory>