Load a Font for the User Session from a Resource

NEW:

Dim pfc As New PrivateFontCollection()

    Private Sub LoadFont()
        Try
            'INIT THE FONT COLLECTION
            pfc = New PrivateFontCollection
            'LOAD MEMORY POINTER FOR FONT RESOURCE
            Dim fontMemPointer As IntPtr =
                Marshal.AllocCoTaskMem(
                My.Resources.Inter_Regular.Length)
            'COPY THE DATA TO THE MEMORY LOCATION
            Marshal.Copy(My.Resources.Inter_Regular,
                         0, fontMemPointer,
                         My.Resources.Inter_Regular.Length)
            'LOAD THE MEMORY FONT INTO THE PRIVATE FONT COLLECTION
            pfc.AddMemoryFont(fontMemPointer,
                               My.Resources.Inter_Regular.Length)
            Marshal.FreeCoTaskMem(fontMemPointer)
        Catch ex As Exception
        End Try
    End Sub
''https://www.vbforums.com/showthread.php?646943-Embeding-fonts-into-NET-application

OLD:

Dim pfc As New PrivateFontCollection()

    Sub InstallFont(FontFileName)

        Dim sTEMPpath As String = Environment.GetEnvironmentVariable("TEMP")

        Try

            My.Computer.FileSystem.WriteAllBytes(sTEMPpath & "\moolatoo.font.ttf", FontFileName, False)

            pfc.AddFontFile(sTEMPpath & "\moolatoo.font.ttf")

        Catch

        End Try

    End Sub

Instantiate the Font

InstallFont(My.Resources.DroidSansMono)

Use the Font

lstEntries.Font = New Font(pfc.Families(0), 11, FontStyle.Regular)

Fonts

.

Press Control key with a letter

Private Sub MyForm_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown

        If (e.KeyCode = Keys.F And e.Control) Then

            Debug.Print("^F Pressed")

            e.SuppressKeyPress = True

            Dim sSearch As String = InputBox("Enter keywords")

            funSearch(sSearch)

        ElseIf e.KeyCode = Keys.F5 Then

            btnRefresh.PerformClick()

        End If

    End Sub