I imported a font that is not supported by the Visual Studio 2012. The code is working but I'm having a problem when the label's boundary and a moving picturebox's boundary touched, the label is having an error (see image below). The error occurs when the form where the 2 objects have been closed using Me.Close() and re-open again by Form1.Show(). For people wondering why I need to close and open it again, I need it for the next level of my simple game.
![Name: error.jpg
Views: 41
Size: 9.7 KB]()
The code is written in my module since I'll use it in many forms. The code is below:
Here's the sample code in my Windows Form:
Note: pixelated.TTF is in my Debug folder.
The code is written in my module since I'll use it in many forms. The code is below:
Code:
Public Function custFont(data As String, ByVal size As Single, ByVal style As FontStyle) As Font
Dim customFfont As Font
Dim pfc = New PrivateFontCollection()
pfc.AddFontFile(Application.StartupPath & data)
customFont = New Font(pfc.Families(0), size, FontStyle.Regular)
Return customFont
End Function
Code:
Public Class Form1
Public Sub form1_Load() Handles MyBase.Load
Label1.Text = "L E V E L 1"
Label1.Font = custFont("\pixelated.TTF", 12, FontStyle.Regular)
End Sub
End Class