Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / October 2007

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
deehen0@gmail.com - 20 Oct 2007 12:45 GMT
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
Alexey Smirnov - 20 Oct 2007 12:54 GMT
> Hi,
>
[quoted text clipped - 10 lines]
>
> 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
Alexey Smirnov - 20 Oct 2007 12:59 GMT
> > Hi,
>
[quoted text clipped - 13 lines]
> 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);
Alexey Smirnov - 20 Oct 2007 13:00 GMT
> > > Hi,
>
[quoted text clipped - 24 lines]
>
> - Show quoted text -

FontFamily ff= p.Families[0];
Göran Andersson - 20 Oct 2007 12:59 GMT
> Hi,
>
[quoted text clipped - 10 lines]
>
> Hensson

Have a look at the PrivateFontCollection class.

Signature

Göran Andersson
_____
http://www.guffa.com

JT - 22 Oct 2007 01:30 GMT
> deeh...@gmail.com wrote:
> > Hi,
[quoted text clipped - 19 lines]
>
> - Show quoted text -

Any chance you can access this font if it resides in your resources?

JT

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.