font importeren

Status
Niet open voor verdere reacties.

bas1278

Gebruiker
Lid geworden
31 mrt 2009
Berichten
139
hallo allemaal,

ik probeer een font te importeren uit een map om in mijn programma te gebruiken.
nu heb ik met google gezocht en kwam ik bij verschillende sites met oplossingen.
maar bij mij wilt het maar niet lukken.

hieronder het script

PHP:
Public Module font
    Public PFC As Drawing.Text.PrivateFontCollection
    Public NewFont_FF As Drawing.FontFamily

    ''' <summary>
    ''' Function to return a new font based on the font file passed to it
    ''' </summary>
    ''' <param name="name">Path to the new font file</param>
    ''' <param name="style">The FontStyle of the new font</param>
    ''' <param name="size">T size of the new font</param>
    ''' <returns>A new font</returns>
    ''' <remarks></remarks>
    Public Function CreateFont(ByVal name As String, ByVal style As Drawing.FontStyle, ByVal size As Single, ByVal unit As Drawing.GraphicsUnit) As Drawing.Font
        'Create a new font collection
        PFC = New Drawing.Text.PrivateFontCollection
        'Add the font file to the new font
        '"name" is the qualified path to your font file
        PFC.AddFontFile(name)
        'Retrieve your new font
        NewFont_FF = PFC.Families(0)

        Return New Drawing.Font(NewFont_FF, size, style, unit)
    End Function

End Module

PHP:
Public Class Form1
    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Label1.Font = CreateFont("pathtofontfile", 12, FontStyle.Regular, GraphicsUnit.Point)
    End Sub
End Class

nu krijg ik alleen een error bij het returnen van de functie.
mijn font is een .ttf ik weet niet of dat er iets mee te maken kan hebben.

Bas
 
Status
Niet open voor verdere reacties.
Terug
Bovenaan Onderaan