Using local font file (.ttf) in asp.net GDI+ app.

  • Thread starter Thread starter deehen0
  • Start date Start date
D

deehen0

Hi,

I am trying to use a special font in an GDI+ application. The font
file is located in my root folder.
The following code does not work but might explain what I am trying to
do...

Font f = new Font(Server.MapPath("somefont.ttf"), 200);

Thank you for your time.

Regards,

Hensson
 
Hi,

I am trying to use a special font in an GDI+ application. The font
file is located in my root folder.
The following code does not work but might explain what I am trying to
do...

Font f = new Font(Server.MapPath("somefont.ttf"), 200);

Thank you for your time.

Regards,

Hensson

Font.Font(String, Single) Constructor has a family name as a first
parameter, not a file name
http://msdn2.microsoft.com/en-us/library/164w6x6z.aspx
 
Font.Font(String, Single) Constructor has a family name as a first
parameter, not a file namehttp://msdn2.microsoft.com/en-us/library/164w6x6z.aspx

P.S.

If you would need to load a font from the file, try following:

PrivateFontCollection p = new PrivateFontCollection();
p.AddFontFile(Server.MapPath("somefont.ttf"));
FontFamily ff= privateFontCollection.Families[0];
Font f = new Font(ff, 200);
 
Hi,

I am trying to use a special font in an GDI+ application. The font
file is located in my root folder.
The following code does not work but might explain what I am trying to
do...

Font f = new Font(Server.MapPath("somefont.ttf"), 200);

Thank you for your time.

Regards,

Hensson

Have a look at the PrivateFontCollection class.
 
On Oct 20, 1:45 pm, (e-mail address removed) wrote:
Font.Font(String, Single) Constructor has a family name as a first
parameter, not a file namehttp://msdn2.microsoft.com/en-us/library/164w6x6z.aspx

P.S.

If you would need to load a font from the file, try following:

PrivateFontCollection p = new PrivateFontCollection();
p.AddFontFile(Server.MapPath("somefont.ttf"));
FontFamily ff= privateFontCollection.Families[0];
Font f = new Font(ff, 200);- Hide quoted text -

- Show quoted text -

FontFamily ff= p.Families[0];
 
Back
Top