Keanu Lorenzo Keanu Lorenzo - 2 months ago 45 Question

Font changes when opened to another computer

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


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