Quantcast
Channel: Programmers Heaven Forums RSS Feed
Viewing all articles
Browse latest Browse all 2703

Embedded Font from Resources is not working on other Systems in VB.NET

$
0
0
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

Viewing all articles
Browse latest Browse all 2703

Trending Articles