Jump to content
  • Advertisement
Sign in to follow this  
Telamon

[.net] Including Fonts as Resources

This topic is 4678 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

If I want to use an unusual font in my C# game, I think it would be a good idea to put it in my game resource folder and package it with the game. Is there a way to load a font from a particular directory to use? I don't want users to have to register my fonts with their system.

Share this post


Link to post
Share on other sites
Advertisement
It's possible to bundle a set of application specific fonts with C#. A good starting point is the System.Drawing.Text.PrivateFontCollection class. In particular pay attention to the AddFontFile() method.

Share this post


Link to post
Share on other sites
Quote:
Original post by cyansoft
You can also compile the font file in the assembly and use it as an embedded resource if you want. Here's some example code on how to load a font embedded in your assembly: http://www.tek-tips.com/faqs.cfm?fid=4747

Bob

There's nothing wrong with SiCrane's method, but I think this is the more advisable route. Fonts are resources just like other resources, and you shouldn't have to do extra work to get them to behave the same way. Instead, you should be able to recycle the resource-loading/using code just as if you were retrieving, say, a localized text string or an icon.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!