   FreeType2 question
  Hi,I just noticed that there is a difference between fonts that I don't quite understand.I try to store characters inside 32x32 areas of a texture.Inside those areas I move the characters down depending on the glyph->bitmap_top value.Pseudo Code: AreaRow = GlyphRow + (x-GlyphBitmapTop)(Result of trial and error)However I have no idea how to find a decent value for x automatically.For some fonts 24 is perfect ... for others it is 28 and so on.Can anybody explain what phenomenon this is?Or is there another way to do the vertical positioning?   
  You really have a mess there, what is the problem? horizontal (x) positioning or vertical?(y)anyway, to get the proper position x,y and size (w,h) this is what I use:pos.x=x;pos.y=y-(FontFace->glyph->bitmap_top)+    FontFace->size->metrics.y_ppem;pos.w=FontFace->glyph->bitmap.width;pos.h=FontFace->glyph->bitmap.rows;That should give you the position to draw the character, use pos.w to figure the next character x position (nextx=x+pos.w).Edit: Actually you get the next horizontal position using glyph->metrics.horiAdvance, there is some fixed point math involved there.   ;  Thanks for the reply! Guess I need to elaborate a little ...this is not the text rendering code. Here I convert a ttf font into a bitmap font.I try to create a texture with all the ASCII characters in it.So the pen position initialy is always the top-left corner of a 32x32 field.Then I try to move the pen down depending on the bitmap_top value and copy the glyph bitmap there.This only works if I adjust a certain offset value. FontFace->size->metrics.y_ppem looked like a candidate ... but using that doesn't seem to help:The left image shows what I want, the right image shows what happens.   ;Quote:Original post by CluelessThanks for the reply! Guess I need to elaborate a little ...this is not the text rendering code. Here I convert a ttf font into a bitmap font.I try to create a texture with all the ASCII characters in it.So the pen position initialy is always the top-left corner of a 32x32 field.Then I try to move the pen down depending on the bitmap_top value and copy the glyph bitmap there.This only works if I adjust a certain offset value. FontFace->size->metrics.y_ppem looked like a candidate ... but using that doesn't seem to help:The left image shows what I want, the right image shows what happens.Ok, first, make sure you are properly converting from 1 byte grayscale to whatever your resolution is, you cant just copy the bitmap over, you are probably doing so, but I guess I lose nothing reminding you [smile].second, if you're just rendering to a font texture, all you need to do is center the glyph on the 32x32 box, you should probably just copy the bitmap and move 32 pixels to the right, copy, move, and so on, when you run out of horizontal space, move 32 pixels down verticaly (x=0 y=current y+texture width*32) and repeat the procedure until you're done.of couse, if you just copy over and move to the next box, you will get the characters offset wrong, but at least they'll print right, once you have that, then start adding the bitmap top variable, refer the code I posted to get that right, in that code x,y is the top left corner of the character bounding box, so adjust in order to get the character centered.Also note that if you're going to then render from the font texture, and your TTF font does not have fixed width, it will look weird unless you save the kerning information somewhere.;  Yes ... what you wrote is pretty much what I am doing.But it produces the evil result I posted.For some fonts the calculated offset for a 'G' should be between 0 and 3 but it is 17.For the ',' it is 29 ... which means the difference between 'G' and ',' is ok.For a different font the offset for a 'G' is 6.So subtracting for example 15 from the offset is not an option.Any ideas what I can do? Somebody must have done something like that successfully before ...   ;  All I can really think of is that some of those values are Fixed Point floating point numbers, make sure you're making the apropriate conversions.Sorry I cant be more help.   