PC Review


Reply
Thread Tools Rate Thread

ArgumentException trying to create a Font that I don't understand

 
 
NeilL
Guest
Posts: n/a
 
      5th Mar 2009
I have a C# application that does something simple like the following

Font newFont = new Font( "Albertus Extra Bold (W1)", 8.5f, FontStyle.Regular);

that throws the following exception:

System.ArgumentException: Font 'Albertus Extra Bold (W1)' does not support
style 'Regular'.
at System.Drawing.Font.CreateNativeFont()
at System.Drawing.Font.Initialize(FontFamily family, Single emSize,
FontStyle style, GraphicsUnit unit, Byte gdiCharSet, Boolean gdiVerticalFont)
at System.Drawing.Font.Initialize(String familyName, Single emSize,
FontStyle style, GraphicsUnit unit, Byte gdiCharSet, Boolean gdiVerticalFont)
at System.Drawing.Font..ctor(String familyName, Single emSize, FontStyle
style)
at TastingMaster.TastingInvitationsForm.GetCurrentFontInfo() in
D:\TastingMaster\Source\TastingMaster\TastingMaster\Tastings\TastingInvitationsForm.cs:line 890

I've looked around and all the posts I've seen seem to say that the font is
corrupted. Since I'm able to use the same font and (I think) with the same
settings it would appear as though the font is not corrupted.

Does anyone have a hint as to what might be the issue here. As a workaround,
is there a way, given the font name, to determine if a particular style is
supported or not?

Thanks

 
Reply With Quote
 
 
 
 
Jeff Johnson
Guest
Posts: n/a
 
      6th Mar 2009
"NeilL" <(E-Mail Removed)> wrote in message
news:8557CB8E-93AE-460D-9CBE-(E-Mail Removed)...

> System.ArgumentException: Font 'Albertus Extra Bold (W1)' does not support
> style 'Regular'.


> I've looked around and all the posts I've seen seem to say that the font
> is
> corrupted. Since I'm able to use the same font and (I think) with the same
> settings it would appear as though the font is not corrupted.


> Does anyone have a hint as to what might be the issue here.


I think the font itself has a hint for you, considering that its name has
the word "bold" in it. That's a pretty big clue that this particular font is
not available in a normal weight.

I don't have "Albertus Extra Bold (W1)" on my system, but I do have
"'Albertus Extra Bold (TrueType)". It's bold only.

> As a workaround,
> is there a way, given the font name, to determine if a particular style is
> supported or not?


The FontFamily class has an IsStyleAvailable() method.


 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I create a bigger font than 72/a scaleable font =?Utf-8?B?Qko=?= Microsoft Word Document Management 1 19th Nov 2007 12:21 AM
File.Create - ArgumentException was unhandled - illegal characters in path Vlad Microsoft VB .NET 4 17th Aug 2007 03:37 PM
Font.GetHeight Method throws an ArgumentException alexey_r@mail.ru Microsoft C# .NET 2 17th May 2006 10:01 PM
ArgumentException NetRacer Microsoft VB .NET 6 18th May 2005 07:46 AM
ArgumentException when create controls. =?Utf-8?B?SG9uZ2FyeQ==?= Microsoft Dot NET Compact Framework 3 13th Jan 2005 10:47 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:23 PM.