0

I have created a WinForm app which has some labels with an special font that is not installed on clients' PCs, so when any of my clients run my app, font of labels are different. I have searched about this to find a solution & there were some options like adding font to resources and then set the properties of any control on app programmatically, so on; but I don't want to change the fonts of controls one by one programmatically! I want to have the labels with my special font when I add them to my app & I want that it looks like mine on cliens' PCs.

First question: How can I do this?

If it's not possible,

Second question: How can I install the fonts on Clients' PCs without letting them know? I mean, how can I install fonts programmatically not just on my project, but for Cliens' OS?

  • technically if you copy the font into `%windir%\fonts` it should be "installed". On the legal side most of the fonts are licensed an cannot be copied onto another computer without infringement. – Franck Jun 04 '18 at 12:02
  • Possible duplicate of [How to install a Font programatically (C#)](https://stackoverflow.com/questions/21986744/how-to-install-a-font-programatically-c) – mjwills Jun 04 '18 at 12:03
  • Have as an additional install within the app. I use a folder that holds the fonts,. The fonts are installed with the app. So it's dedicated to the app and not other programs. – Halonic Jun 04 '18 at 12:03
  • I used this example from code project https://www.codeproject.com/articles/107377/load-and-use-custom-font-without-installing-it I did some tweaking from what he done. But it's a good start. – Halonic Jun 04 '18 at 12:07
  • @Halonic As is said, this is a little bit difficult to set the properties of each control programmatically. because: 1. UI design on vs & the running app on a client's PC is going to be different ( on size, style, etc ) 2. Controls are too much :) –  Jun 04 '18 at 12:14

2 Answers2

0

Your question is rather broad as you are asking two things.

For your first question, might as well replace all text through the solution which matches. If I remember correctly design files are included with that.

For your second question you want to make a installer. You can create a installer for your program with http://wixtoolset.org/ There are enough tutorials around to get you starting. To include your (custom) font try; How to install Open Type Fonts using Wix

usselite
  • 846
  • 7
  • 24
  • for first question: If I have added the fonts to resources, shouldn't I code for anything? I mean there is no need to add any script to declare that app should use the font which is added to resources? adding them to resources is enough? –  Jun 04 '18 at 12:05
  • Well yes, the comment from @mjwills which refers to https://stackoverflow.com/questions/21986744/how-to-install-a-font-programatically-c solves that if you direct that from your resource folder. The fonts need to be found/registered by the system. Yet, you don't have to code it if you make a installer with Wix or Installshield. The admin can install the specific font for everyone on that machine. – usselite Jun 04 '18 at 12:17
0

For these scenarios you will need to write a script for deployment. Typically these things are done via Installation packages. Your font has to be packaged with the application. And then either your main application or some other script should be run to install the font. Here are some links,

Install font via command line

Wix Installer

Windows Installer

Code Name Jack
  • 2,856
  • 24
  • 40