Sign in to follow this  
sdlprorammer

SDL Your method for text

Recommended Posts

:'( 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..

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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..?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
I personally use the freetype library (http://www.freetype.org/)in combination with FTGL (http://homepages.paradise.net.nz/henryj/code/), but, of course I use opengl under sdl, so if you are sticking with conventional sdl surfaces you'd be best with sdl_ttf as the other guys suggest, but i've never used it personally so I don't know much about it.

Share this post


Link to post
Share on other sites
I personally drew out all the ansi characters i was gonna use, put them all in one big image, then used some inherited classes from my tile engine.

Share this post


Link to post
Share on other sites
What about if you incorporate OpenGL into your SDL game? Doesn't OpenGL come with some font rendering functions? If you only need 2D fonts, which do you think would be more appropriate, OpenGL font functions or SDL_ttf functions???

Share this post


Link to post
Share on other sites
Roots: that depends on what you are looking for, there are font libraries that render antialiased text, 3d geometery text, bitmap fonts... the lot, or there are simpler, lighter libraries that only do bitmap fonts for example. It really depends what you are looking for. Bitmap fonts are perfectly ok for just about any use, but characters in true type fonts are not restrained to one height and width as bitmap fonts are.

There are some font functions available under glut if your are using opengl but last I looked they are pretty limited.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this