PDA

View Full Version : SDL Text



code_glitch
24-11-2009, 08:11 PM
Is there any EASY way to get text onto a surface in SDL? I've looked at this http://www.freepascal-meets-sdl.net/ but I find it a bit too, uhh, complicated for what I want to achieve (but i do understand it). I have also fiddled around with SDL and let it spit out as many errors as I can take in one day. My main complaint is: I don't need the background colour, and do you have to load a font from hd? I want to make it cross-platform and I doubt you find fonts at C:\Windows on a linux machine.

And if there is no really easy way, can I use wingraph/graph to do so instead and have it work on the same screen/surface?

Any help would be veeeery nice please...

Stoney
24-11-2009, 08:59 PM
Is there any EASY way to get text onto a surface in SDL? I've looked at this http://www.freepascal-meets-sdl.net/ but I find it a bit too, uhh, complicated for what I want to achieve (but i do understand it). I have also fiddled around with SDL and let it spit out as many errors as I can take in one day. My main complaint is: I don't need the background colour, and do you have to load a font from hd?

You can use bitmap fonts, for example SFont which is included in JEDI-SDL package along with some examples. It's really easy to use, but has a few disadvantages like no unicode support.

You could also load fonts from streams (SDL_RWops or TStream) or alternatively load the font from a website (that would require to establish a connection using SDL_net/SDL_web, downloading the file onto the hard disk or writing a stream containing the font, and deleting the file/freeing the stream if the application has been closed.)



I want to make it cross-platform and I doubt you find fonts at C:\Windows on a linux machine.

The best way is to distribute the fonts with your games and not to load the fonts with an absolute path.

code_glitch
25-11-2009, 07:51 AM
so there is no general command I take it? That's a shame :(
out of interest, what sdl unit come with freepascal 2.2.4? are they the JEDI-SDL untis or sdl4fpc units? and does it amke a difference?

Stoney
25-11-2009, 03:58 PM
so there is no general command I take it? That's a shame :(


There is no built-in font in SDL.



out of interest, what sdl unit come with freepascal 2.2.4? are they the JEDI-SDL untis or sdl4fpc units? and does it amke a difference?


As far as I know the SDL units shipped with FreePascal are modified JEDI-SDL units, for example link automatically against the SDL libaries on Linux.
SDL4FreePascal was last updated in 2001, so it is not as up-to-date as JEDI-SDL.
But the units shipped with FreePascal are just the core SDL (and SDL friends) units, like SDL, SDL_mixer, SDL_ttf, SDL_image and so on.

code_glitch
25-11-2009, 07:17 PM
ah I see. thanks for that explanation. I'm kinda new to SDL so still learning the ropes :D