473,413 Members | 1,778 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,413 software developers and data experts.

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

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

Oct 20 '07 #1
5 3672
On Oct 20, 1:45 pm, deeh...@gmail.com wrote:
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

Oct 20 '07 #2
On Oct 20, 1:54 pm, Alexey Smirnov <alexey.smir...@gmail.comwrote:
On Oct 20, 1:45 pm, deeh...@gmail.com wrote:
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 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);

Oct 20 '07 #3
On Oct 20, 1:59 pm, Alexey Smirnov <alexey.smir...@gmail.comwrote:
On Oct 20, 1:54 pm, Alexey Smirnov <alexey.smir...@gmail.comwrote:


On Oct 20, 1:45 pm, deeh...@gmail.com wrote:
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 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];

Oct 20 '07 #4
de*****@gmail.com wrote:
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.

--
Göran Andersson
_____
http://www.guffa.com
Oct 20 '07 #5
JT
On Oct 20, 7:59 am, Göran Andersson <gu...@guffa.comwrote:
deeh...@gmail.com wrote:
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.

--
Göran Andersson
_____http://www.guffa.com- Hide quoted text -

- Show quoted text -
Any chance you can access this font if it resides in your resources?

JT

Oct 22 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: alex | last post by:
Hi, I am looking for a way to populate an HTML table from an external local text file which looks like this: DATE/TIME LAT. LON. DEPTH. ML....
2
by: linearfusion | last post by:
Hello, I may not have worded the subject correctly, but what I am trying to do is pull the XML data from the following stream,...
4
by: Chuck Anderson | last post by:
My Web Host (Linux - Apache) recently upgraded to Php5. One thing lost in the upgrade was a global configuration that allowed me to place php.ini files in any directory and they would be read and...
5
by: =?Utf-8?B?Qkw=?= | last post by:
Hello friends In c# 2005 I have written a function to access "font file name" by "Font name" and it is working fine in all the windows version other than vista, in vista it is throughing an...
0
by: ashokformac | last post by:
Hi to everybody, how to find the font file size...when i find the size of a font file using file.lengh() function , it returns 0 for font file . For other file it is returning the correct file...
2
by: Nesster13 | last post by:
Hi, I am building an application that will utilize the local resource file. Right now the application is separated into two part, the header and the content. One of the line at the top of the...
2
by: ashokformac | last post by:
I am developing a program in java on mac os .. when i try to find filesize it is giving me '0 long' on font file(actual size is some 2000 bytes ) but on other files it is working properly ... ...
1
by: sachinkale123 | last post by:
I m creating multilingual Website. I m using Local Resource file. Applaying culture runtime. I did applied it to 3 Pages, for them it is perfectly working but now It has stopped to apply culture to...
0
by: Andreas Tawn | last post by:
-----Original Message----- g] On Behalf Of Steve Holden Can't help with a recipe, but here's the formal spec if want to figure it out yourself. ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.