Implementing wglUseFontBitmaps

Hello,

I am trying to write my own version of wglUseFontBitmaps but it seems to mess up the character spacing sometimes. i am really stumped. any help much appreciated.

code:

BOOL GLTUseFontBitmaps( HDC hdc, // DC with font
DWORD firstChar, // First character
DWORD numChars, // Number of Chars
DWORD dispListBase, // Starting display)
{

// 2D Rotation matrix.
// Uses fixed point representation

MAT2 mat2;

// Identity matrix

// I thought this would be 1,1 but maybe it is because
// of the OpenGL/Windows origin differences?

mat2.eM11.fract =  0;
mat2.eM11.value =  1;

mat2.eM12.fract =  0;
mat2.eM12.value =  0;

mat2.eM21.fract =  0;
mat2.eM21.value =  0;

mat2.eM22.fract =  0;
mat2.eM22.value = -1;

GLYPHMETRICS gm;

// The bitmap returned by GetGlyphOutline is a DWORD-aligned row-oriented
// array of 1 byte values.

glPixelStorei(GL_UNPACK_ALIGNMENT, sizeof(DWORD));

for(int i = 0; i < (int)numChars; i++)
{
	BYTE *pBuffer = NULL;

	// Call once to establish the size of the buffer

	int iSize = GetGlyphOutline(hdc,
								firstChar + i,
								GGO_BITMAP,
								&gm,
								0,
								NULL,
								&mat2);

	pBuffer = new BYTE[iSize];

	// Get the bitmap bits into the struct with a 2nd call

	GetGlyphOutline(hdc,
					firstChar + i,
			        GGO_BITMAP,
					&gm,
					iSize,
					pBuffer,
					&mat2);

	// Build the display list

	glNewList (dispListBase + i, GL_COMPILE);

	glBitmap(gm.gmBlackBoxX,
		     gm.gmBlackBoxY,
			 gm.gmptGlyphOrigin.x,
			 gm.gmptGlyphOrigin.y,
			 gm.gmCellIncX,
			 gm.gmCellIncY,
			 pBuffer);
	
	glEndList();

	delete [] pBuffer;

}

return TRUE;

}