pevhs.ch ~/prog/

uvcalc

This utility calculates UV coordinates of monospace characters based on given dimensions. It needs to know the size of the characters to generate and the dimensions of the texture they should be used on. Example:

$ uvcalc -sS 11x21 64x64
0.000000 1.000000 0.171875 1.000000 0.000000 0.671875 0.171875 0.671875
0.171875 1.000000 0.343750 1.000000 0.171875 0.671875 0.343750 0.671875
0.343750 1.000000 0.515625 1.000000 0.343750 0.671875 0.515625 0.671875
0.515625 1.000000 0.687500 1.000000 0.515625 0.671875 0.687500 0.671875
0.687500 1.000000 0.859375 1.000000 0.687500 0.671875 0.859375 0.671875
0.000000 0.671875 0.171875 0.671875 0.000000 0.343750 0.171875 0.343750
0.171875 0.671875 0.343750 0.671875 0.171875 0.343750 0.343750 0.343750
0.343750 0.671875 0.515625 0.671875 0.343750 0.343750 0.515625 0.343750
0.515625 0.671875 0.687500 0.671875 0.515625 0.343750 0.687500 0.343750
0.687500 0.671875 0.859375 0.671875 0.687500 0.343750 0.859375 0.343750
0.000000 0.343750 0.171875 0.343750 0.000000 0.015625 0.171875 0.015625
0.171875 0.343750 0.343750 0.343750 0.171875 0.015625 0.343750 0.015625
0.343750 0.343750 0.515625 0.343750 0.343750 0.015625 0.515625 0.015625
0.515625 0.343750 0.687500 0.343750 0.515625 0.015625 0.687500 0.015625
0.687500 0.343750 0.859375 0.343750 0.687500 0.015625 0.859375 0.015625
$

Here, the program was able to fit 15 characters of 11x21 on a texture of 64x64. A line is composed of 2D vectors corresponding to the top-left, top-right, bottom-left and bottom-right of a character. As you can see, (0;0) is assumed to be at the bottom-left of the image.

You can also give it the following optional arguments:

-v
Be verbose. print the number of characters generated and when the program starts filling a new line.
-h
Print the help text and quit.
-n
Define the number of characters to generate. If the texture is too small to contain them all, the program will stop and throw an error.

I created this utility to generate character maps for my program progle. It's really basic, but works well enough for me.

The character map used in progle...

...And the text appearing in-game.

Source.