Ehsan Habib
Ehsan Habib

Reputation: 135

Installing fonts with my application using C#

I am developing a project in C# where I need digital-7 font. Previously I have used InnoSetup for making my C# application files to setup files which could be install in any PC. I have never modified InnoSetup code.

I found this Link but I didn't understand anything. Somehow I tried a demo software where I added my font files like this

Source: "C:\Users\DEVJEET MANDAL\Downloads\digital-7\digital-7 (italic).ttf"; DestDir: "{fonts}"; FontInstall: "digital-7"; Flags: ignoreversion
Source: "C:\Users\DEVJEET MANDAL\Downloads\digital-7\digital-7 (mono italic).ttf"; DestDir: "{fonts}"; FontInstall: "digital-7"; Flags: ignoreversion onlyifdoesntexist uninsneveruninstall
Source: "C:\Users\DEVJEET MANDAL\Downloads\digital-7\digital-7 (mono).ttf"; DestDir: "{fonts}"; FontInstall: "digital-7"; Flags: ignoreversion onlyifdoesntexist uninsneveruninstall
Source: "C:\Users\DEVJEET MANDAL\Downloads\digital-7\digital-7.ttf"; DestDir: "{fonts}"; FontInstall: "digital-7"; Flags: ignoreversion onlyifdoesntexist uninsneveruninstall
Source: "C:\Users\DEVJEET MANDAL\Downloads\digital-7\readme.txt"; DestDir: "{fonts}"; FontInstall: "digital-7"; Flags: ignoreversion onlyifdoesntexist uninsneveruninstall

While installing I get this error

ADD FONT RESOURCE FAILED

I am totally new to this. Can anyone give some insight about this?

Upvotes: 0

Views: 694

Answers (1)

Andrew Truckle
Andrew Truckle

Reputation: 19087

You could consider making use of Inno Script Studio for this issue.

Select Install Fonts... from the Project menu:

enter image description here

Then, select your fonts. For example:

enter image description here

The file(s) get added to the script for you at the location of the cursor. This should be in the [Files] section of your script. For example:

Source: "C:\Windows\Fonts\digital-7 (italic).ttf"; DestDir: "{fonts}"; FontInstall: "Digital-7 Italic"; Flags: onlyifdoesntexist uninsneveruninstall
Source: "C:\Windows\Fonts\digital-7 (mono italic).ttf"; DestDir: "{fonts}"; FontInstall: "Digital-7 MonoItalic"; Flags: onlyifdoesntexist uninsneveruninstall
Source: "C:\Windows\Fonts\digital-7 (mono).ttf"; DestDir: "{fonts}"; FontInstall: "Digital-7 Mono"; Flags: onlyifdoesntexist uninsneveruninstall
Source: "C:\Windows\Fonts\digital-7.ttf"; DestDir: "{fonts}"; FontInstall: "Digital-7"; Flags: onlyifdoesntexist uninsneveruninstall

It will get the FontInstall parameter correct which is your problem. See this question for reference.

You have given them all the same FontInstall value which is wrong. To quote the help:

Tells Setup the file is a font that needs to be installed. The value of this parameter is the name of the font as stored in the registry or WIN.INI. This must be exactly the same name as you see when you double-click the font file in Explorer. Note that Setup will automatically append " (TrueType)" to the end of the name.

Upvotes: 1

Related Questions