Search code examples
nsis

How to install fonts?


If I just use File to install fonts, installation goes fine, but the fonts are useless: no characters show up when you try to write with them, and if you doubleclick them in a fonts folder, their preview would be blank.

So far I tried to follow this guide, with this snippet of code:

FindFirst $5 $6 "..\3rdparty\fonts\*.ttf"
loop:
    StrCmp $6 "" done
    !insertmacro InstallTTFFont $6
    FindNext $5 $6
    Goto loop
done:
FindClose $5

However, I get this error:

!insertmacro: InstallTTFFont Push: $0 Push: $R0 Push: $R1 Push: $R2 !define: "Index"="Line66.6" !insertmacro: GetFileNameCall Push: $6 Call "GetFileName" Pop: $0 !insertmacro: end of GetFileNameCall !define: "FontFileName"="$0" SetOutPath: "$FONT_DIR" IfFileExists: "$FONT_DIR\$0" ? Line66.6 : File: "$6" -> no files found. Usage: File [/nonfatal] [/a] ([/r] [/x filespec [...]] filespec [...] |
/oname=outfile one_file_only) Error in macro InstallTTFFont on macroline 14 Error in script "C:\ScanModule\Install\ScanModule.nsi" on line 66 -- aborting creation process

Edit: If I just manually write out all of the individual fonts, it works. So problem solved. Sorta. Not that I'm complaining, but that's not cool.


Solution

  • I have 4 thoughts about it:

    1. Did you try also quotes?

      !insertmacro InstallTTFFont "$6"

    2. Is FindFirst ... loop performed on developer's machine or on user's machine? I am not sure how it works and if implementation fits to you.

    3. I see you use relative path "..\3rdparty\fonts*.ttf". What is working directory in time you launched the command?

    4. You could also add something like this into the C:\ScanModule\Install\ScanModule.nsi to understand why only manually wrote fonts work.

      MessageBox MB_OK "Param 0: $0"