SDL Your method for text

Started by
13 comments, last by sckoobs 19 years, 8 months ago
:'( This really pisses me off. Not being able to print text in the screen is painful ( you can only draw it with images ). So i thought someone could be using something different instead of always having to have a special image with the aphabet to print text. Do you all include the text image in the data folder of your projects, or do you do a magical trick? Thanks..
Advertisement
Check out SDL_ttf at http://www.libsdl.org/projects/SDL_ttf/
- daeron
What daeron said. SDL_ttf is probably the best solution to display text with SDL. It even supports Unicode and anti-aliased fonts.

It doesn't rely on a font being installed in the user's system. You supply the font yourself with your game. (I'm mentioning this because this is what scared me off at first from using a TTF library.)

If you want something simpler (in terms of size; SDL_ttf is easier to use), check out SFont at http://www.linux-games.com/sfont/ - it loads fonts from an image file. Of course, it's restricted to ASCII characters.

SDL_gfx also includes a simple, built-in font renderer including a font.
---Just trying to be helpful.Sebastian Beschkehttp://randomz.heim.at/
thank you for the replies... but SDK__ttf does require you to supply a font ( http://jcatki.no-ip.org/SDL_ttf/SDL_ttf_frame.html ). or am i wrong?

edit how do i make a link work..?
Quote:Original post by sdlprorammer
thank you for the replies... but SDK__ttf does require you to supply a font ( http://jcatki.no-ip.org/SDL_ttf/SDL_ttf_frame.html ). or am i wrong?

edit how do i make a link work..?
Yes, you have to suppy a font. Google for the "Bitstream Vera" fonts, which very nice, and freely redistributable.

Links are plain html:
<a href="http://www.website.com">text to show</a>

Don't forget the http:// part, or it won't work.
Or you can just make your own text fucntions, it takes only a few hours of coding, and you get some experience as well, plus you don't need any dependencies, and you can customize it to whatever extent you want.
ok thank you all!
IIRC, the SDL_ttf demos file comes with a couple of fonts which may be used freely. Those are from the freefonts project.
---Just trying to be helpful.Sebastian Beschkehttp://randomz.heim.at/
ok..
Try SFont.

It's great if you don't want to use a font file, but want to use a bitmap font, which for me, was easier than creating a .ttf for my font.

Really simple and easy to use.

-Skitzo

This topic is closed to new replies.

Advertisement