S
Softlin
Guest
Without installation font support only label1. but TextBox1 not supporting we must install font. How to support font without installation font in TextBox1. Code is under below kindly check this and solve this issue.
**********************************************************************************************
Imports System.Reflection
Imports System.Drawing.Text
Imports System.Runtime.InteropServices
Imports System.IO
Imports System.Resources
Public Class Form1
Public _pfc As PrivateFontCollection = Nothing
Public ReadOnly Property GetFont(ByVal Size As Single, ByVal style As FontStyle) As Font
Get
If _pfc Is Nothing Then LoadFont()
Return New Font(_pfc.Families(0), Size, style)
End Get
End Property
Public Property StartingIndex As Integer
Private Sub LoadFont()
_pfc = New PrivateFontCollection
Dim FontMemPointer As IntPtr = Marshal.AllocCoTaskMem(My.Resources.MyFont.Length)
Marshal.Copy(My.Resources.MyFont, StartingIndex, FontMemPointer, My.Resources.MyFont.Length)
_pfc.AddMemoryFont(FontMemPointer, My.Resources.MyFont.Length)
Marshal.FreeCoTaskMem(FontMemPointer)
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Label1.Font = GetFont(20, FontStyle.Regular)
TextBox1.Font = GetFont(20, FontStyle.Regular)
End Sub
End Class
Continue reading...
**********************************************************************************************
Imports System.Reflection
Imports System.Drawing.Text
Imports System.Runtime.InteropServices
Imports System.IO
Imports System.Resources
Public Class Form1
Public _pfc As PrivateFontCollection = Nothing
Public ReadOnly Property GetFont(ByVal Size As Single, ByVal style As FontStyle) As Font
Get
If _pfc Is Nothing Then LoadFont()
Return New Font(_pfc.Families(0), Size, style)
End Get
End Property
Public Property StartingIndex As Integer
Private Sub LoadFont()
_pfc = New PrivateFontCollection
Dim FontMemPointer As IntPtr = Marshal.AllocCoTaskMem(My.Resources.MyFont.Length)
Marshal.Copy(My.Resources.MyFont, StartingIndex, FontMemPointer, My.Resources.MyFont.Length)
_pfc.AddMemoryFont(FontMemPointer, My.Resources.MyFont.Length)
Marshal.FreeCoTaskMem(FontMemPointer)
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Label1.Font = GetFont(20, FontStyle.Regular)
TextBox1.Font = GetFont(20, FontStyle.Regular)
End Sub
End Class
Continue reading...