OT: Comic Balloons

Hello Guys,

Where can I find some info about drawing comic balloons as well as 

wordwrapping it’s contents? I started doing on my own, but it’s not perfect
:frowning:

Thanks!–
Eduardo B. Fonseca
ebf at aedsolucoes.com.br
10:10:51 up 2 days, 12:01, 1 user, load average: 0.15, 0.17, 0.70

Eduardo B. Fonseca wrote:

Hello Guys,

Where can I find some info about drawing comic balloons as well as
wordwrapping it’s contents? I started doing on my own, but it’s not perfect
:frowning:

Thanks!

you can use one of the many font and text libraries for SDL to wrap the
text and just draw the ballon one of many ways: pre-made image, draw
with resizable curves, whatever. you could construct it with ‘left
side’, ‘right side’ ‘top’ and ‘bottom’ image parts where they can be
stretched to any size.

you can use one of the many font and text libraries for SDL to wrap the
text and just draw the ballon one of many ways: pre-made image, draw
with resizable curves, whatever. you could construct it with ‘left
side’, ‘right side’ ‘top’ and ‘bottom’ image parts where they can be
stretched to any size.

What about SDL_ttf? does it support wordwrapping?

Thanks!–
Eduardo B. Fonseca
ebf at aedsolucoes.com.br
22:53:17 up 3 days, 42 min, 1 user, load average: 0.15, 0.04, 0.01

that’s a very good question. does anybody know? i ended up having to
write my own wrapping code, as sdl_ttf seemed to just deal w/ rendering
and loading fonts and nothing else (which is quite reasonable as that’s
what it’s meant for).

– chris (@Christopher_Thielen)On Mon, 2003-03-17 at 17:53, Eduardo B. Fonseca wrote:

you can use one of the many font and text libraries for SDL to wrap the
text and just draw the ballon one of many ways: pre-made image, draw
with resizable curves, whatever. you could construct it with ‘left
side’, ‘right side’ ‘top’ and ‘bottom’ image parts where they can be
stretched to any size.

What about SDL_ttf? does it support wordwrapping?

Thanks!

Yep. That’s all it does. Wordwrapping is pretty trivial though.

More or less:

void render_wordwrapped(SDL_Surface * dstsurf, char * str,
int x, int y, int w, TTF_Font * font,
Uint8 color)
{
char myword[128]; /* Some reasonably-large size */
int i, len, cur_x;
SDL_Surface * ttfsurf;
SDL_Rect dest;

myword[0] = '\0';
len = 0;
cur_x = x;
cur_y = y;

for (i = 0; i <= strlen(str); i++)   /* '<=' to grab that last null :^) */
{
  if (str[i] != ' ' && str[i] != '\0')
  {
    myword[len++] = str[i];
    myword[len] = '\0'
  }
  else
  {
    /* A break between words (or end of string)!  Renderin' time ! */

    ttfsurf = TTF_RenderText_Blended(font, myword, color);

    if (cur_x + ttfsurf->w > x + w)
    {
      /* This word would go off the edge; move down a line! */

      cur_x = x;
      cur_y = cur_y + ttfsurf->h;  /* Mightn't be best way to find height */
    }

    dest.x = cur_x;
    dest.y = cur_y;

    SDL_BlitSurface(ttfsurf, NULL, dstsurf, &dest);
  }
}

I just wrote this into my e-mail client, so I don’t even know if it’s
syntactically correct, but you should get the idea.

An example call to this function might be:

render_wordwrapped(my_surf, “Hello there! This is so much fun!”,
0, 0, 320, my_font,
SDL_MapRGB(my_surf->format, 0, 0, 0)); /* black */

Good luck!

-bill!On Mon, Mar 17, 2003 at 06:38:41PM -0800, Christopher Thielen wrote:

that’s a very good question. does anybody know? i ended up having to
write my own wrapping code, as sdl_ttf seemed to just deal w/ rendering
and loading fonts and nothing else (which is quite reasonable as that’s
what it’s meant for).


bill at newbreedsoftware.com Hire me!
http://newbreedsoftware.com/bill/ http://newbreedsoftware.com/bill/resume/