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 / Windows Forms / WinForm General / February 2005

Tip: Looking for answers? Try searching our database.

Possible bug using non system fonts

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Thomas René Sidor - 16 Feb 2005 15:01 GMT
Hi there.

I've for the past few days been experimenting with the use of non system
fonts via the PrivateFontCollection.AddFontFile() method.

If i do something like this:
private void button1_Click(object sender, System.EventArgs e)
       {
           System.Drawing.Text.PrivateFontCollection pfc = new
System.Drawing.Text.PrivateFontCollection();
           pfc.AddFontFile("FREE3OF9.TTF");

           FontFamily fam = new FontFamily("Free 3 of 9", pfc);
           Font f = new Font(fam, 10F);
           this.listBox1.Items.Add(f);
       }

and clicks the button about 5 times or so, the font objects get messed up
and thrwos an exception in, among others, the name property.

Any suggestions?
Chris Dunaway - 16 Feb 2005 22:11 GMT
What exception?

Each time you click the button, it creates a NEW font collection.  Is
that what you intend?  What if you declared the pfc variable in a
global location and only instantiate it once?

Just some random thoughts

Chris
Thomas René Sidor - 16 Feb 2005 22:27 GMT
Actually I've just solved the problem some hours ago. I didn't know that the
font objects needed the FontCollection, so I only declared the FontCollection
locally, and when it got out of scope and got collected by the garbage
collector - the font objects got messed up.

But thanks for the suggestions.

Best regards
Thomas Rene Sidor

> What exception?
>
[quoted text clipped - 5 lines]
>
> Chris

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.