SDL_ttf iterating through glyphs

Hi,

I’ve been using SDL for a while now in conjunction with OpenGL, and recently started to add true type font rendering to my engine. Anyway, I’ve been using SDL_ttf to render each available glyph to a SDL_Surface, and then using that to create a texture, which I use to draw text.

My issue is that the SDL_tff interface doesn’t provide any way of iterating through the available glyphs. The only way to determine which glyphs are available is to iterate through all possible Uint16 charcodes(65 536), and using TTF_GlyphIsProvided. I noticed that the freetype 2.0 library does provide a way of iterating through all available Glyphs using FT_Get_First_Char and FT_Get_Next_Char like this:

Code:

/* From the Freetype manual */
FT_ULong charcode;
FT_UInt gindex;

charcode = FT_Get_First_Char( face, &gindex );
while ( gindex != 0 )
{
… do something with (charcode,gindex) pair …

charcode = FT_Get_Next_Char( face, charcode, &gindex );
}

For my build of the library I added two small wrapper functions for FT_Get_First_Char and FT_Get_Next_Char. I was wondering if there was a particular reason why there isn’t something of equivalence in the SDL_ttf interface, and if it would be possible to incorporate it into the next release of the library.

Thanks for listening.

Nope, this would be easy to add, although if you’re going to be using
FreeType directly with OpenGL, is there value to using SDL_ttf in between
them?On Thu, Feb 10, 2011 at 9:11 PM, Darcy Rayner <darcy.rayner at gmail.com>wrote:

Hi,

I’ve been using SDL for a while now in conjunction with OpenGL, and
recently started to add true type font rendering to my engine. Anyway, I’ve
been using SDL_ttf to render each available glyph to a SDL_Surface, and then
using that to create a texture, which I use to draw text.

My issue is that the SDL_tff interface doesn’t provide any way of iterating
through the available glyphs. The only way to determine which glyphs are
available is to iterate through all possible Uint16 charcodes(65 536), and
using TTF_GlyphIsProvided. I noticed that the freetype 2.0 library does
provide a way of iterating through all available Glyphs using
FT_Get_First_Char and FT_Get_Next_Char like this:

Code:

/* From the Freetype manual */
FT_ULong charcode;
FT_UInt gindex;

charcode = FT_Get_First_Char( face, &gindex );
while ( gindex != 0 )
{
… do something with (charcode,gindex) pair …

charcode = FT_Get_Next_Char( face, charcode, &gindex );
}

For my build of the library I added two small wrapper functions for
FT_Get_First_Char and FT_Get_Next_Char. I was wondering if there was a
particular reason why there isn’t something of equivalence in the SDL_ttf
interface, and if it would be possible to incorporate it into the next
release of the library.

Thanks for listening.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


-Sam Lantinga, Founder and CEO, Galaxy Gameworks