Strange sdl_ttf print error

Started by
5 comments, last by Sylvarant 16 years, 11 months ago
I'm experiencing strange errors with text printing using sdl_ttf when i pass anything to my print function that contains a space in it for example tprint(100,100,"some thing",font,black); it doesn't print it, but when i take away the space like this tprint(100,100,"something",font,black); it does print something ?? very strange. /*----------------------------------------------------------------------------------/ // TPRINT // thoda print function for printing text /----------------------------------------------------------------------------------*/ void tprint(int x, int y,std::string var,TTF_Font* var2,SDL_Color var3) { // render the text SDL_Surface * message = TTF_RenderText_Solid(var2,var.c_str(),var3); // apply the images to the screen apply_surface( x, y, message, screen); } I'm compiling this in Kdevelop in ubuntu 7.04 with all sdl libarys correctly linked
Sylvarant @www.gamedesign.be
Advertisement
I've never had a problem with SDL_ttf and spaces. Tabs and newlines don't work, but spaces have always worked for me. Does it print anything? What does TTF_RenderText return, if it is NULL what is the value of TTF_GetError() return?

BTW, give your function parameters meaningful names. I would write:
void tprint(int x, int y, std::string value, TTF_Font* font, SDL_Color colour);


It is preferable to pass std::string instances by const reference rather than by value, which makes that:
void tprint(int x, int y, const std::string &value, TTF_Font* font, SDL_Color colour);
when there's no space in the string it outputs something like 0x80ab3a0
but whenever there's a space in the string it's simply 0

very strange
Sylvarant @www.gamedesign.be
Quote:Original post by Sylvarant
when there's no space in the string it outputs something like 0x80ab3a0
but whenever there's a space in the string it's simply 0

very strange


What outputs that value, TTF_Render or TTF_GetError?

Try something like this:
void tprint(int x, int y,std::string var,TTF_Font* var2,SDL_Color var3){// render the textSDL_Surface * message = TTF_RenderText_Solid(var2,var.c_str(),var3);if( message ){   // apply the images to the screen   apply_surface( x, y, message, screen);}else{   printf("%s",TTF_GetError());}} 

Then check the output in stdout.txt.
when a string with a space in it is passed to the functions it simply outputs

Text has zero width

it also outputs
Failed loading DPMSDisable: /usr/lib/libX11.so.6: undefined symbol: DPMSDisable
in the very beginning
Sylvarant @www.gamedesign.be
Quote:Original post by Sylvarant
when a string with a space in it is passed to the functions it simply outputs

Text has zero width

it also outputs
Failed loading DPMSDisable: /usr/lib/libX11.so.6: undefined symbol: DPMSDisable
in the very beginning


Odd. See here too. What version of SDL_ttf are you using? Do you get the same results with the latest version?
thanx for the link apparently the error wad due to something in freetype
Sylvarant @www.gamedesign.be

This topic is closed to new replies.

Advertisement