1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| Private ReadOnly _FontCollection As New PrivateFontCollection()
Private Sub GetMyFontRessources(ByVal CB As ComboBox)
For Each MyFont As String In Assembly.GetEntryAssembly().GetManifestResourceNames
If MyFont.ToLower.EndsWith(".ttf") Then
Using fontStream As Stream = Assembly.GetEntryAssembly().GetManifestResourceStream(MyFont)
If Not (fontStream Is Nothing) Then
Dim data As System.IntPtr = Runtime.InteropServices.Marshal.AllocCoTaskMem(fontStream.Length)
Dim fontdata() As Byte = New Byte(fontStream.Length - 1) {}
fontStream.Read(fontdata, 0, fontStream.Length)
Marshal.Copy(fontdata, 0, data, fontStream.Length)
_FontCollection.AddMemoryFont(data, fontStream.Length)
fontStream.Close()
Marshal.FreeCoTaskMem(data)
Dim MyLangue As New FontFamily(_FontCollection.Families.Last.Name, _FontCollection)
CB.Items.Add(MyLangue.Name)
End If
End Using
End If
Next
End Sub |
Partager