Hello Guest

stbtt_GetCodepointBox and stbtt_GetFontVMetrics inconsistent values

  • 1 Replies
Hi, im trying to display a font with a pixel height of 150 but if i multiply the quad values from calling stbtt_GetBakedQuad with the scale factor from stbtt_ScaleForPixelHeight the result is ridiculously large.

So I tried to calculate the scalefactor myself by using the tallest character height and the window height, however the height from calling stbtt_GetCodepointBox varies hugely with the difference in y0 and y1 for "1" being 709 and "2" being 441 even though they are similar in height. it is the same for stbtt_GetFontVMetrics as the difference in ascent and descent being 2288 while the value for a "(" which is one of the taller characters only being 883.

Can anyone explain why there is such a large difference in the heights for the characters?

here is the code im using and the font is Arial

Code: [Select]
loadedFontData = IOUtil.ioResourceToByteBuffer(source,512 * 1024);

            for(int i = 32; i < 126;i++)
                IntBuffer x0 = BufferUtils.createIntBuffer(1);
                IntBuffer x1 = BufferUtils.createIntBuffer(1);
                IntBuffer y0 = BufferUtils.createIntBuffer(1);
                IntBuffer y1 = BufferUtils.createIntBuffer(1);

                int test1 = y0.get(0);
                int test2 = y1.get(0);

                int difference = test2 - test1;



Offline spasi

  • *****
  • 2206
    • WebHotelier
Re: stbtt_GetCodepointBox and stbtt_GetFontVMetrics inconsistent values
« Reply #1 on: September 03, 2019, 20:46:22 »
Looks like you got the parameter order wrong. The correct is: x0, y0, x1, y1.