2

On some fonts, I can't get SDL_TTF to render some glyphs (such as …), even when I know they are present (if I use the same font in, say, gedit, it works fine).

Makefile:

test: test.c
    gcc -o test -ansi -pedantic -Wall test.c `sdl-config --cflags --libs` -lSDL_ttf

Example (test.c):

#include <SDL/SDL.h>
#include <SDL/SDL_ttf.h>

int main(int argc, char *argv[]) {
    SDL_Init(SDL_INIT_EVERYTHING);
    TTF_Init();

    {
        SDL_Event ev;
        SDL_Color color = {255,255,255};
        SDL_Surface *win = SDL_SetVideoMode(640, 480, 16, SDL_HWSURFACE | SDL_DOUBLEBUF);
        TTF_Font *drawfont = TTF_OpenFont("./ProggySquareSZ.ttf", 22);
        SDL_Surface *text_surface = TTF_RenderUTF8_Solid(drawfont,"…",color);
        SDL_Rect r = {10, 10, 0, 0};
        SDL_BlitSurface(text_surface,NULL,win,&r);

        SDL_Flip(win);
        while(SDL_WaitEvent(&ev)) {
            if(ev.type == SDL_QUIT) break;
        }
    }

    return 0;
}
genpfault
  • 51,148
  • 11
  • 85
  • 139
singpolyma
  • 10,999
  • 5
  • 47
  • 71

1 Answers1

2

This font has no .

Name: ProggySquareTTSZ
Supported Unicode Blocks
    0x0000 - 0x00FF   ANSI

A horizontal ellipsis has U+2026 code, it more than 0x00FF(255).

Probably you see in gedit because in some operating systems and software, if a certain character is not found in the font, it's being replaced with same from more similar font, installed in the OS, and then displayed.

tehten
  • 156
  • 5
  • That sounds possible. Where did you get that information that you included? I'd like to be able to analyze other fonts to see if the contain glyphs I need. – singpolyma Nov 13 '12 at 15:30
  • I use old Total Commander plugin named wlxFont. You may found it here http://users.telenet.be/liontech/Downloads.htm. I think there are also other programs for display of information about fonts, just google it. – tehten Nov 13 '12 at 16:23
  • Аlso in sdl_ttf there is a [TTF_GlyphIsProvided](http://www.libsdl.org/projects/SDL_ttf/docs/SDL_ttf.html#SEC37) function with which you can see if there is a character in the font. – tehten Nov 13 '12 at 16:45