I have been using the popular LMNOpc font builder: http://games.ucla.ed...ont-builder-pc/

This generates a 256x256 bitmap, with 16x16 pixel tiles, each with a font character inside.

I can easily calculate the pixel coordinates for each tile, using:

[source lang="csharp"] newTexturePositions[0] = new Vector2(textX*16,textY*16); // 0: top left newTexturePositions[1] = new Vector2((textX+1)*16,textY*16); // 1: top right newTexturePositions[2] = new Vector2(textX*16,(textY+1)*16); // 2: bottom left newTexturePositions[3] = new Vector2((textX+1)*16,(textY+1)*16); // 3: bottom right[/source]

But of course I need the cartesian coordinates - i.e. values between 0 and 1 for texture coordinates (I presumed).

So I thought I'd transform the vectors using an orthogonal matrix (LH - which I used for all sprite rendering to good effect thus far), set to a 256x256 pixel size.

This gives me the following transformed vectors in the case of the tile at (1,1):

... before transformation for textX = [1], textY = [1]

newTexturePositions[0] = [X:16 Y:16]

newTexturePositions[1] = [X:32 Y:16]

newTexturePositions[2] = [X:16 Y:32]

newTexturePositions[3] = [X:32 Y:32]

... AFTER transformation for textX = [1], textY = [1]

newTexturePositions[0] = [X:-0.875 Y:0.875]

newTexturePositions[1] = [X:-0.75 Y:0.875]

newTexturePositions[2] = [X:-0.875 Y:0.75]

newTexturePositions[3] = [X:-0.75 Y:0.75]

However, this does not map as expected.

This is the font bitmap I'm using:

**courier_new_10_lmno.bmp**

**192.05KB**46 downloads

And this is what I get mapped to my sprite...

**fontlolz1.bmp**

**23.82KB**44 downloads

Two things are very wrong here. Firstly it's not a single tile being mapped - I'm getting four. Secondly it's not even in the right area of the bitmap.

So the question is, how do I generate the right texture coordinates? I'm missing a trick quite desperately here. I thought it would be quite simple...