Jump to content
  • Advertisement
Sign in to follow this  
ZeMag

Text in SDL

This topic is 4348 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

Hi, is it possible to use fonts types that I have in windows with SDL? I know I can make my own 'font' (load the characters from a .bmp file), but it seams like unnecessary work and I'm not able to change the sizes in an easy manner. I tried to find something about this in the files that come with SDL, but I didn't found anything. Thanks for the help.

Share this post


Link to post
Share on other sites
Advertisement
Check out (if you dont already know it):

Cone3D

Lesson 4 is about bitmap fonts. I remember that inside it, somewhere, there was a link explaining how to create new fonts...

Share this post


Link to post
Share on other sites
Quote:
Original post by ZeMag
is it possible to use fonts types that I have in windows with SDL?


Yes, what you will need to take a look at is SDL_ttf. As per its name, it allows you to use TTF fonts (of which most of your Windows fonts are) in your SDL applications. You can take a look though the documentation online here as well (something highly recommended). For an example, take a look at the demo code (latin1.c).

The general procedure for using SDL_ttf is pretty simple:
* Call TTF_Init() after SDL has been initialized to setup the library.
* Load the font with a call to TTF_OpenFont();
* Render the text/glyph to a surface with a call to the corresponding TTF_Render[X]_[Y] function.
* Close the font with a call to TTF_CloseFont();
* Call TTF_Quit() before SDL has been deinitialized to cleanup the library.

That's just a brief outline of the simplest operations. Once again, read over the documenation because it gives examples of all of the functions that you can use to quickly get working. Good luck!

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!