Thread: TTF_Font to GL Display List Kerning issue

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    May 2012
    Posts
    12

    TTF_Font to GL Display List Kerning issue

    [Edit] Forgot to mention that although the font looks like it has an outline, that's just part of the font. The actual true-type font looks like that, haha. Also, I can end up with it looking like this http://i.imgur.com/x6jl5.jpg, which is better, if I remove the first glTranslate to "minx", but the spacing still looks wrong. [/Edit]

    I'm working on font code in my SDL_GL application, using SDL_TTF. The code to generate and call the display list is working, but the spacing looks off: http://i.imgur.com/7Fan7.jpg

    The relevant section of code is this section:

    Code:
        glNewList(list+ch, GL_COMPILE);
        glBindTexture(GL_TEXTURE_2D, tex[ch]);
        int minx, maxx, miny, maxy, advance;
        TTF_GlyphMetrics(Font, ch, &minx, &maxx, &miny, &maxy, &advance);
        glPushMatrix();
        glTranslated(minx, miny, 0);
        glBegin(GL_QUADS);
            glTexCoord2f(0, 0); glVertex2i(0, 0);
            glTexCoord2f(1, 0); glVertex2i(sText->w, 0);
            glTexCoord2f(1, 1); glVertex2i(sText->w, sText->h);
            glTexCoord2f(0, 1); glVertex2i(0, sText->h);
        glEnd();
        glPopMatrix();
        glTranslated(advance, 0, 0);
        glBindTexture(GL_TEXTURE_2D, 0);
        glEndList();
    Is the advance part of glyph metrics in SDL_TTF just not good enough? I tried switching "glTranslated" to "glTranslatef", but TTF_GlyphMetrics returns ints and not floats so it doesn't change anything.
    Last edited by Alexander Edgar; 05-08-2012 at 04:30 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 13
    Last Post: 05-02-2012, 04:17 PM
  2. Display a hex value in a list box?
    By klipseracer in forum Windows Programming
    Replies: 5
    Last Post: 01-27-2008, 10:46 AM
  3. Nested for loop...search & display a list within a list
    By chadsxe in forum C++ Programming
    Replies: 13
    Last Post: 07-20-2005, 01:34 PM
  4. Dual Display issue
    By psychopath in forum Tech Board
    Replies: 8
    Last Post: 02-12-2005, 12:02 PM
  5. Display list not displaying?
    By psychopath in forum Game Programming
    Replies: 5
    Last Post: 09-19-2004, 06:47 PM