Advertisement

Support for latin characters

Started by January 27, 2005 01:52 PM
6 comments, last by Tsumuji 19 years, 7 months ago
The lessons 17, 24 and 43 do not support characters like á, à, é, ê, ç, ã, and simmilars? And tried with different .ttf files for lesson 43, but doesn't work. What can be modified for this to work? Thanks in advance.
Lessons 17 and 24 create the fonts from an image, so you need to have the wanted characters in the font.

In lesson 43, you have to make sure you create characters for the whole 256 character range, not just for first 128.

Hint:
// Here We Ask OpenGL To Allocate Resources For// All The Textures And Display Lists Which We// Are About To Create.  list_base=glGenLists(128);glGenTextures( 128, textures );// This Is Where We Actually Create Each Of The Fonts Display Lists.for(unsigned char i=0;i<128;i++)	make_dlist(face,i,list_base,textures);


Finally, if you are placing accented characters in your source file, remember that the source file encoding may differ from the font's glyph locations (i.e. what is an à in the source file may correspond to a þ in the font, if the encodings to not match).
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
Advertisement
Hi there... I posted quite the same thing a few days ago... you can check it Here
Well, unfortunally, I got into no conclusion at all, and I'm still not able to do it... could you send me a word if you get it right??
I changed the 128 numbers, by a 256, but doesn't work at all. The ttf loaded, but is showed like before. Some more Hint? :D
I think I'm in a serious problem....
does the font u use has the characters u need ? - some fonts like "Arial","Tahoma" have a different character set inside them but many doesn't.

* when u create font with "CreateFont" u can define character set and then u can draw the characters u want(see Lesson: 13).
latin characters are within the first 256 characters

'à' = 224, 'á' = 225, 'ê' = 233, 'é' = 234. 'ç' = 231, 'ã' = 227

the majority of fonts will contain these characters (even Courier does)
Advertisement
Ok... I kind of got it working... on Nehe Lesson13.

changed:
base = glGenLists(96); (note that 96 = 128 - 32) to:
base = glGenLists(256 - 32);

GLvoid KillFont(GLvoid)
{
glDeleteLists(base, 96);
}
to:
glDeleteLists(base, 256 - 32);

I don't know why this doesn't work on Lesson 24 or other ones, I think that's because of the way the texture was generated, but I'm not shure... don't know what to do in these cases.
I could'nt make this work in any way. Maybe the SDL_ttf works? But I can't get this thing to work properly. I can't see the result in my screen.

TTF_Font *font;SDL_Color fg;...	videoFlags  = SDL_OPENGL;          	videoFlags |= SDL_GL_DOUBLEBUFFER; 	videoFlags |= SDL_HWPALETTE;      	videoFlags |= SDL_RESIZABLE;     surface = SDL_SetVideoMode( SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP, videoFlags );...font=TTF_OpenFont("Test.ttf", 16);		if(!font) {			printf("TTF_OpenFont: %s\n", TTF_GetError());		}		fg.r = 255;		fg.g = 255;		fg.b = 128;...surface = TTF_RenderText_Solid(font,"Hello World!", fg );


Is that right?

This topic is closed to new replies.

Advertisement