MAKEMSI quickly and reliably creates MSI files in a non-programmatic way
Have your say! Join the MAKEMSI discussion list or view archive! Suggest improvements. No question too simple or too complex.
[Bottom][Contents][Prev]: File and Directory[Next]: Browse Dialog - Changing Directory
Have your say! Join the MAKEMSI discussion list or view archive! Suggest improvements. No question too simple or too complex.
\->Tips and Tricks->File and Directory->Add Fonts

Add Fonts

This page shows how you can install fonts. It defines a reusable macro (best placed in your personal MAKEMSI configuration file), and demonstrates how the macro can be used to install font files.

STEP #1 - Create Reusable Macro

The Windows Installer "Font" table is updated when defining fonts and this requires a "File" table's row key (to the actual font file) so notice the use of the "?" on the "RowKey" parameter of the "File" command.

Define the reusable macro:

;--- Create a macro to add font files (reusable command, place into common header file) ---
#(
   #define FontFile

   ;--- Add the file (remember the MSI "File" table's key) ------------------
   <$File RowKey="?RxFontFileKey" {$?}>  ;;Add file (forwarding all parameters), record file key

   ;--- Add to the font table -----------------------------------------------
   <$Table "Font">
       <$Row File_="<??RxFontFileKey>">
   <$/Table>
#)

A reused macro makes your code much easier to read and greatly reduces the risk of an error. Any error in the macro is usually quickly picked up in testing, but if not when you fix the macro you fix all future versions of MSIs making use of it.

STEP #2 - Use the Macro to install Font Files

Now Use the macro we defined above (note that the "FontsFolder" directory is a Windows Installer system folder property):

;--- Now test the above macro (add some true type fonts) --------------------
<$Component "FontFiles" Create="Y" Directory_="FontsFolder">
   ;--- Add some individual TrueType fonts ----------------------------------
   <$FontFile Source="Font1.TTF">
   <$FontFile Source="Font2.TTF">

   ;--- Now add all font's in a particular directory ------------------------
   #evaluate ^^ ^call Files4Mask "fonts\*.ttf", "@@Fonts"^
   #{  for @@I = 1 to @@Fonts.0                               ;;@@Fonts.0 holds count of files found
       #info ^Adding font "<??@@Fonts.@@i $$FilePart:NAME>"^  ;;Display filename without path on console
       <$FontFile Source="<??@@Fonts.@@i>">                   ;;Call predefine macro to add font.
   #}
<$/Component>


Microsoft awarded me an MVP (Most Valuable Professional award) in 2004, 2005, 2006, 2007, 2008 & 2009 for the Windows SDK (Windows Installer) area.Please email me any feedback, additional information or corrections.
See this page online (look for updates)

[Top][Contents][Prev]: File and Directory[Next]: Browse Dialog - Changing Directory


MAKEMSI© is (C)opyright Dennis Bareis 2003-2008 (All rights reserved).
Saturday May 28 2022 at 3:11pm
Visit MAKEMSI's Home Page
Microsoft awarded me an MVP (Most Valuable Professional award) in 2004, 2005, 2006, 2007, 2008 & 2009 for the Windows SDK (Windows Installer) area.