Original Post
Hello! I'm trying to implement simple bitmap fonts and I'm running into some problems. First of all, here's the 64x64 image font, it's fixed-width for simplicity. Each character is 9x9 :
Here how it renders
Each character's uv rect seems to offset to the left as it approaches the right edge of the texture and it also seem to offset up when it approaches the lower edge of the texture. I can't understand why. Here's my setup code : When rendering, I look each character of the string in the character map to get the uvRect and I draw a rectangle with those uv coordinates. Anyone has an idea of why this is happening?
Here how it renders
Each character's uv rect seems to offset to the left as it approaches the right edge of the texture and it also seem to offset up when it approaches the lower edge of the texture. I can't understand why. Here's my setup code : Real pixelSize = (Real)1/(Real)64; // texture coordinate size of 1 pixel
for(UInt j = 0 ; j < 6 ; ++j) // Each row
{
for(UInt i = 0 ; i < 7 ; ++i) // Each col
{
Math::Rect * uvRect = Null;
UInt index = i+j*7;
// m_characters is a std::map<char, Math::Rect>
if(index <= 25) uvRect = &m_characters['A' + (char)index];
else if(index <= 35) uvRect = &m_characters['0' + (C8)(index-25)];
else uvRect = &m_characters[0];
// setMinSize(minx, miny, width, height)
uvRect->setMinSize(i*9*pixelSize, j*9*pixelSize, 9*pixelSize, 9*pixelSize);
}
}