ASP.NET text in image

  • Thread starter Thread starter marko
  • Start date Start date
M

marko

I have created a small script in ASP.NET using VB.NET for creating pictures
with text inside. Now I have a problem how to use my own font directory, and
not Windows system fonts directory.

How to read available fonts an put on of them into the objFont? Thanks!

m.
 
This is the part of code that works fine now.

objFont = new Font("Verdana", 8)
objGraphics.DrawString(sTextToGenerate, objFont, Brushes.Black, 1, 1)


How to read available fonts and put one of them into the objFont? Thanks!
 
Well, if the font is stored on the server..I think it should pick it up.
Never tried it
 
Tampa.NET Koder said:
Well, if the font is stored on the server..I think it should pick it up.
Never tried it

Well, it should, but my ISP has forbidden access to WINDOWS/Fonts directory.
So, I need to have my own /Fonts. I don't know how to read *.ttf into the
..Net framework and "say" to it to use those. I was googling a little bit,
but with no success. If someone knows how to write a few lines of code in
VB.... :o)
 
// Load font
string fontName = Request.Form.Get("fontname") + ".ttf";
PrivateFontCollection privateFontCollection = new
PrivateFontCollection();
privateFontCollection.AddFontFile(Server.MapPath("./") + fontName);

FontFamily fontFamily = privateFontCollection.Families[0];
 
Ersin Gençtürk said:
// Load font
string fontName = Request.Form.Get("fontname") + ".ttf";
PrivateFontCollection privateFontCollection = new
PrivateFontCollection();
privateFontCollection.AddFontFile(Server.MapPath("./") + fontName);

FontFamily fontFamily = privateFontCollection.Families[0];


Thanks! It helped me and the problem is solved :)

m.
 

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

Back
Top