include fonts in c# application form after publishing

155 Views Asked by At

**i have created a project and publish it using fonts loading on my windows which i have installed on my windows .... it's working on my pc but when i open the published application on other devices its not showing the fonts . how can include those fonts on the project than publish it so when i install the application on other devices i can see fonts desgin **

how can i add those fonts on the project so the application loading fonts from project not on my windows fonts

** i have tried some codes but it's not working at all **

1

There are 1 best solutions below

3
Kieran Devlin On BEST ANSWER

Add the font file into the project and copy the file to the output directory on every build.

enter image description here

Then load the font from the same directory as your application via a relative path.

    var fontCollection = new PrivateFontCollection();

    fontCollection.AddFontFile("myFontFile.otf");

    label.Font = new Font(fontCollection.Families[0], 40);

enter image description here