Using System.Drawing for a Custom Font

J

jjbutera

I have a custom font installed on my machine, but I can't seem to use
it with System.Drawing.

Dim f As New Font("MyCustomFontName", 20, FontStyle.Regular)

This just gives me the default of Arial. Is there something I should
know? Is there only a specific set of fonts that can be used with the
Font class?


Thanks,

Jason
 
J

jjbutera

Thanks,

I found the PrivateFontCollection which can do what I want!
' Load Font
Dim fontName As String = "myfont.ttf"
Dim pfcoll As New System.Drawing.Text.PrivateFontCollection
pfcoll.AddFontFile(Server.MapPath("~\" & fontName))
Dim ff As FontFamily = pfcoll.Families(0)
Dim f As New Font(ff, 11, FontStyle.Regular)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,234
Latest member
SkyeWeems

Latest Threads

Top