etscrivner Pretty, Pretty Fairy Princess
Joined: 30 Jun 2007 Posts: 9 Location: California
|
Posted: Thu Jul 12, 2007 3:46 am Post subject: SDL_ttf Weirdness. |
[quote] |
|
Hi All,
I'm not sure what is going on here, but absolutely every value passed into TTF_GlyphMetrics checks out, but for some reason it still segfaults when it hits that line - I've also tried using several different fonts. The fonts are loaded through SDL_RWops and TTF_LoadFontRW. Here's the code, i'm just trying to implemented glyph caching for speed-ups since I'm working with OpenGL.
Any help is sincerely appreciated in advance.
Code: |
void symphony::Font::_CacheChar(char ch)
{
// If the character is within range then attempt to cache it
GLfloat texcoord[4];
char letter[2] = {0};
if(_ttf_font == NULL)
{
return;
}
if((ch >= symphony::resource::GLYPH_MIN_LIMIT) &&
(ch <= symphony::resource::GLYPH_MAX_LIMIT) &&
(_glyphs.find(ch) == _glyphs.end()))
{
SDL_Surface* g0 = NULL;
SDL_Surface* g1 = NULL;
letter[0] = ch;
symphony::resource::FontGlyph* glyph = new symphony::resource::FontGlyph();
int min_x, max_x;
int min_y, max_y;
int advance;
if(TTF_GlyphMetrics(_ttf_font,
ch,
&min_x,
&max_x,
&min_y,
&max_y,
&advance) < 0)
{
std::cerr << "GlyphMetrics failed: " << TTF_GetError() << std::endl;
}
std::cerr << "Past TTF_GlyphMetrics (" << min_x << ", " << advance << ")" << std::endl;
delete glyph;
}
}
|
|
|