Can't work out "top-side" bearing or "horiBearingY" in TrueType #1275
-
For a few days now I have been struggling a bit to calculate the vertical metrics of characters in my game. What I need are these values shown in the image: Maybe I seem stupid by saying this... I tried calculating the bearingY from the image above, but the vertical positions of the characters were messed up. I just don't understand how to get this value. I searched all over the internet and tried a lot, but I can't work it out. Can somebody help? Here is my code, if it helps. In the first function I retrieve the metrics and in the second I fill up the OpenGL buffer needed for drawing:
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
I think the docs in the file are pretty clear?
|
Beta Was this translation helpful? Give feedback.
I think the docs in the file are pretty clear?
STBTT_DEF void stbtt_GetCodepointBitmapBox(const stbtt_fontinfo *font, int codepoint, float scale_x, float scale_y, int *ix0, int *iy0, int *ix1, int *iy1);
// get the bbox of the bitmap centered around the glyph origin; so the
// bitmap width is ix1-ix0, height is iy1-iy0, and
location to place
// the bitmap top left is (leftSideBearing*scale,iy0).
// (Note that the bitmap uses y-increases-down, but the shape uses
// y-increases-up, so CodepointBitmapBox and CodepointBox are inverted.)