Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click MyControl.Font = MyControl.GetSymbology(RabtaysoftSize, FontStyle.Regular) End Sub '************* Call Dll property **************** Public ReadOnly Property GetSymbology(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 _pfc Nothing Then LoadMyFnontAreal() 'RETURN A NEW FONT OBJECT BASED ON THE SIZE AND STYLE PASSED IN Return New Font(_pfc.Families(0), Size, style) End Get End Property Public Property StartingIndex128 As Integer Private Sub LoadMyFnontAreal() Try 'INIT THE FONT COLLECTION _pfc = New PrivateFontCollection 'LOAD MEMORY POINTER FOR FONT RESOURCE Dim fontMemPointer128 As IntPtr = Marshal.AllocCoTaskMem(My.Resources.MyFontAreal.Length) 'COPY THE DATA TO THE MEMORY LOCATION Marshal.Copy(My.Resources.MyFontAreal, StartingIndex128, fontMemPointer128, My.Resources.MyFontAreal.Length) 'LOAD THE MEMORY FONT INTO THE PRIVATE FONT COLLECTION _pfc.AddMemoryFont(fontMemPointer128, My.Resources.MyFontAreal.Length) 'FREE UNSAFE MEMORY Marshal.FreeCoTaskMem(fontMemPointer128) Catch ex As Exception 'ERROR LOADING FONT. HANDLE EXCEPTION HERE End Try End Sub
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)