*fancy* text with SDL_ttf?

Hi

I’m looking for tips on how to create fancy text using SDL_ttf. What I’m
after is text like Macromedia “Fireworks” can generate. Such effects as:

  • Alpha blended drop shadow
  • Alpha blended “glow” around text
  • Textured text characters
  • Variable size/colour outline around each character

oh…and with all the above nicely anti-aliased too :slight_smile:

Can I use SDL_ttf for this or should I be looking elsewhere…?

Any tips/help/comments appreciated :slight_smile:

Thanks, Paul.

At this time SDL_ttf is only a simple wrapper to FreeType 2.0 library. If
you need such effects you have to code them yourself using rasterized
surface or trying to play with FreeType itself and make them vector based.

Anyway does someone know about SDL_ttf update? I’m looking for support for
some kind of transformations like rotate, skew and scale. As far I know
FreeType supports them…

Regards, Pavel Kanzelsberger> ----- Original Message -----

From: Paul [mailto:krushka@iprimus.com.au]
Sent: Friday, February 22, 2002 2:39 PM
To: sdl at libsdl.org
Subject: [SDL] fancy text with SDL_ttf?

Hi

I’m looking for tips on how to create fancy text using SDL_ttf. What I’m
after is text like Macromedia “Fireworks” can generate. Such effects as:

  • Alpha blended drop shadow
  • Alpha blended “glow” around text
  • Textured text characters
  • Variable size/colour outline around each character

oh…and with all the above nicely anti-aliased too :slight_smile:

Can I use SDL_ttf for this or should I be looking elsewhere…?

Any tips/help/comments appreciated :slight_smile:

Thanks, Paul.


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Paul wrote:

I’m looking for tips on how to create fancy text using SDL_ttf. What I’m
after is text like Macromedia “Fireworks” can generate. Such effects as:

  • Alpha blended drop shadow
  • Alpha blended “glow” around text
  • Textured text characters
  • Variable size/colour outline around each character

oh…and with all the above nicely anti-aliased too :slight_smile:

this may not quite help you, but maybe it will. in december the pygame
folks had a little “font contest” where people tried to do some simple
creative effects with fonts. the code is all in python, but could easily
be turned into c code. if you go in pixel by pixel in c you could even
make them a bit fancier.

as far as antialiasing goes, most people quickly ran into problems with
SDL’s lack of handling the pixel alphas in the destination surface.
therefore most of the effects just use colorkeys to get around this.

anyways, you can check out the results and maybe get some ideas. there’s
stuff like dropshadows, outlines, and even some animated entries.
http://www.pygame.org/fontcontest.shtml

I’m looking for tips on how to create fancy text using SDL_ttf. What I’m
after is text like Macromedia “Fireworks” can generate. Such effects as:

  • Alpha blended drop shadow
  • Alpha blended “glow” around text
  • Textured text characters
  • Variable size/colour outline around each character

OpenGL?
You can load the glyph image into a GL_ALPHA texture and use the GL_REPLACE
texture function. This is used to add an alpha channel to a simple color, or (with
multitexturing) to a GL_RGB ‘real’ texture. Then you can scale/shift/rotate/draw multiple
times as you like. And enable blending.

oh…and with all the above nicely anti-aliased too :slight_smile:

You get it for free with GL_LINEAR texture filtering.

Can I use SDL_ttf for this or should I be looking elsewhere…?

This is connected to another thread on this list - creating textures from SDL surfaces. I do
not know about 2D SDL, so maybe keep watching it…

I don’t know SDL_ttf, but if it is a simple wrapper around freetype, you may look at the
source or use plain freetype - all you need is an area of memory with the glyph grayscale
image and dimensions a power of 2.

Hope this helps,

Carsten

Paul wrote:

Hi

I’m looking for tips on how to create fancy text using SDL_ttf. What I’m
after is text like Macromedia “Fireworks” can generate. Such effects as:

  • Alpha blended drop shadow
  • Alpha blended “glow” around text
  • Textured text characters
  • Variable size/colour outline around each character

oh…and with all the above nicely anti-aliased too :slight_smile:

Can I use SDL_ttf for this or should I be looking elsewhere…?

Any tips/help/comments appreciated :slight_smile:

They only question seems to be whether or not SDL_ttf supports outline
rendering with variable outline width. I don’t know. If you can render
with black on white with antialiasing you can use that as alpha
channel for other effects. (Draw black rectangle with blit alpha set
to 50% and use slitgly shifted rendered text as alpha channel for drop
shadow etc.)–
Mikko