1

Why is my program's font changes when opened in another device/computer? Here is a of what the effect is when opened to another device and what it should look like originally. The left side is what it looks like when opened in another device and the right side is what it should be. Any help is very much appreciated. The color changes everytime and is controlled with a timer, if you're wondering.

enter image description here

Reza Aghaei
  • 120,393
  • 18
  • 203
  • 398
Keanu Lorenzo
  • 79
  • 1
  • 14
  • Belongs the selected font to a TrueType Fonts? – Leo Chapiro Nov 02 '16 at 12:56
  • @duDE I believe the font that I was using in this program was "Monotype Corsiva". – Keanu Lorenzo Nov 02 '16 at 13:25
  • 1
    Well, this is a less common font and you have installed it on your developer system. Now you are going with your program to another system - the font is missing here. So either you take a common True Type font (better choice) or you install this "Monotype Corsiva" on the target system. – Leo Chapiro Nov 02 '16 at 13:28
  • @duDE I really like this font in that particular program. So my choice is to install the font to the target system. How do I do it? – Keanu Lorenzo Nov 02 '16 at 13:38
  • 1
    Take a look at a link that @Reza Aghael already posted: http://stackoverflow.com/questions/727053/how-do-i-embed-a-font-with-my-c-sharp-application-using-visual-studio-2005 . So you can embed the font into your application. – Leo Chapiro Nov 02 '16 at 13:43

1 Answers1

2

If the assigned font doesn't exits on the target system it uses the default font family to render the string.

Also you don't assign Font to a form explicitly, it uses DefaultFont which returns SystemFonts.DefaultFont which depends to system settings and may be different in different systems. If you need to have similar font in all systems, assign a font to Font propery of your form explicitly.

You can embed the font into your application. Also if your application comes with an installer you can deploy the font on target machine. For example add a font to your project and set its Copy To Output Directory to Copy Always, then you can use the font this way:

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    Dim fontCollection = New PrivateFontCollection()
    fontCollection.AddFontFile(Path.Combine(Application.StartupPath, "MyFont.ttf"))
    Dim font = New Font(fontCollection.Families(0), 12)
    Me.Font = font
End Sub
Community
  • 1
  • 1
Reza Aghaei
  • 120,393
  • 18
  • 203
  • 398