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>