Не хотите устанавливать шрифт в папку шрифтов windows
Я не хочу устанавливать "MyFontAreal.ttf" в папку шрифтов windows, потому что у меня есть определение "MyFontAreal.ttf" в папке ресурсов в dll-файле. Любая возможность без установки.
Что я уже пробовал:
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