I've a font embedded from resources. on my System it's working perfectly (Win XP). but when I try to test the executable on other System (Only Windows 7), everything is working fine, bu embedded font is not showing up. It is applied on a label.
Public ReadOnly Property GetInstance(ByVal Size As Single, _
ByVal style As FontStyle) As Font
Get
'IF THIS IS THE FIRST TIME GETTING AN INSTANCE
'LOAD THE FONT FROM RESOURCES
If fntCollect Is Nothing Then LoadFont()
'RETURN A NEW FONT OBJECT BASED ON THE SIZE AND STYLE PASSED IN
Return New Font(fntCollect.Families(0), Size, style)
End Get
End Property
Private Sub LoadFont()
Try
'INIT THE FONT COLLECTION
fntCollect = New PrivateFontCollection
'LOAD MEMORY POINTER FOR FONT RESOURCE
Dim fontMemPointer As IntPtr = _
Marshal.AllocCoTaskMem( _
My.Resources.DIGITAL.Length)
'COPY THE DATA TO THE MEMORY LOCATION
Marshal.Copy(My.Resources.DIGITAL, _
0, fontMemPointer, _
My.Resources.DIGITAL.Length)
'LOAD THE MEMORY FONT INTO THE PRIVATE FONT COLLECTION
fntCollect.AddMemoryFont(fontMemPointer, _
My.Resources.DIGITAL.Length)
'FREE UNSAFE MEMORY
Marshal.FreeCoTaskMem(fontMemPointer)
Catch ex As Exception
MsgBox("Sorry! Error Loading Digital Font.")
End Try
End Sub
ASP.Net Web Development
Public ReadOnly Property GetInstance(ByVal Size As Single, _
ByVal style As FontStyle) As Font
Get
'IF THIS IS THE FIRST TIME GETTING AN INSTANCE
'LOAD THE FONT FROM RESOURCES
If fntCollect Is Nothing Then LoadFont()
'RETURN A NEW FONT OBJECT BASED ON THE SIZE AND STYLE PASSED IN
Return New Font(fntCollect.Families(0), Size, style)
End Get
End Property
Private Sub LoadFont()
Try
'INIT THE FONT COLLECTION
fntCollect = New PrivateFontCollection
'LOAD MEMORY POINTER FOR FONT RESOURCE
Dim fontMemPointer As IntPtr = _
Marshal.AllocCoTaskMem( _
My.Resources.DIGITAL.Length)
'COPY THE DATA TO THE MEMORY LOCATION
Marshal.Copy(My.Resources.DIGITAL, _
0, fontMemPointer, _
My.Resources.DIGITAL.Length)
'LOAD THE MEMORY FONT INTO THE PRIVATE FONT COLLECTION
fntCollect.AddMemoryFont(fontMemPointer, _
My.Resources.DIGITAL.Length)
'FREE UNSAFE MEMORY
Marshal.FreeCoTaskMem(fontMemPointer)
Catch ex As Exception
MsgBox("Sorry! Error Loading Digital Font.")
End Try
End Sub
ASP.Net Web Development