Author Topic: Easiest way to display text in SDL?  (Read 3844 times)

Stephanie

  • Guest
Easiest way to display text in SDL?
« on: May 23, 2010, 04:51:20 pm »
I've got a little project I'm doing and I'm looking for a cheap & cheerful way to display a single line of text.

I've found a tutorial for using the SDL TTF function, which is what's used in dmenu, but I'm looking for something even simpler - I'm sure I've seen something where a bmp or png is used to make a graphic text map then the characters are read from that, but I can't find any examples.

The main reason I don't want to use the TTF stuff is that I don't want to have to bundle a ttf font with my app, I want it to be all self-contained and not require any external files so I figure that the graphic font thing was a better choice since it gets compiled in.

Thanks!

darfgarf

  • Guest
Re: Easiest way to display text in SDL?
« Reply #1 on: May 23, 2010, 04:57:31 pm »
if it's just a single line, such as loading... etc, then just do it as a bitmap.

if it needs to generate the text, then display something dynamic, instead of hard coded/etc, then sdl_ttf is probably the easies thing to use.  any other way would still involve some sort of font file, or a big bitmap with the characters on.

so it all depends on what you need to do with it

Stephanie

  • Guest
Re: Easiest way to display text in SDL?
« Reply #2 on: May 23, 2010, 05:27:15 pm »
Thanks for the info!

It is dynamic / generated text I need to display.

If I use the TTF functions, can I compile the font right into the binary? Or does the font need to be installed on the dingoo alongside the binary?  The tutorial I found doesn't say, and the example I have (dmenu) stores the fonts on the dingoo in a resources directory.

darfgarf

  • Guest
Re: Easiest way to display text in SDL?
« Reply #3 on: May 23, 2010, 06:19:11 pm »
uhm...no idea, if there's a simple way of referencing a file in the executable and it working normally, then theoretically, yes  ;D

Stephanie

  • Guest
Re: Easiest way to display text in SDL?
« Reply #4 on: May 23, 2010, 10:24:29 pm »
I've got it working using the ttf method. You do need to have the ttf file in there with the binary, but at least it works.

The project was an updated version of ViewImage.

Thanks for the help!

wejp

  • Posts: 36
    • wejpsite
Re: Easiest way to display text in SDL?
« Reply #5 on: May 30, 2010, 08:47:26 am »
If you are still interested in how to use bitmap fonts, you could have a look at the Gmu source code, where I have implemented drawing text using bitmap fonts. While I load the characters from a separate file, you could easily embed the characters bitmap into the binary (e.g. as xpm).

 

Post a new topic
Post a new topic