The question is answered, right answer was accepted
How do I calculate custom font character texture uvs from .fnt file
So i made a little .fnt file using shoebox and it was nothing else but a text file that contained some stuff about character positions/sizes on the image (in my case format of image is 186x189), and the main part of that .fnt file looks like this:
char id=65 x=93 y=26 width=16 height=25 xoffset=0 yoffset=55 xadvance=17 page=0 chnl=0 letter="A"
so the most important info that I get from that are x,y,width and height. Like this:
And in the custom font index is the id and the there are 2 rects, one is Vert where I just add W = width and H = -height and after that one there is the Uv rect and I need a few formulas how to calculate those uvs from those x,y,width and height values from fnt file. As far as I know values there are in range from 0 to 1 so to calculate x and w I just divided x and width by image width and that worked, but when I tried the same with y and h and divided them by image height I haven't got the correct uv values and instead of getting letter A i got... (part of the image that is... not 'a'), so what is the right formula to calculate those y and h values?
Answer by ado112 · Feb 27, 2016 at 02:37 PM
After a few hours of "thinking", I ended up with this:
UV.x = x / imageWidth;
UV.y = (imageHeight - (y+height)) / imageHeight;
UV.w = width / imageWidth;
UV.h = height / imageHeight;
Vert.x = 0;
Vert.y = -yoffset;
Vert.w = width;
Vert.h = -height;