Text display issue in ported code - help needed

I am in the process of porting some OpenGL code, written in C/C++, to Java, but my inexperience with text display is causing me problems. The relavent C/C++ code is as follows:


void TextOut(double x, double y, double size, char *str, bool ident)
{
	gl.glMatrixMode(GL.GL_MODELVIEW);
	gl.glPushMatrix();

	if (ident)
		gl.glLoadIdentity();

	gl.glColor3d(1,1,1);
	gl.glTranslatef(x,y,0);
	gl.glScalef(size, size, size);
	
	QFont fnt;
	fnt.setPointSize(size*2);
	renderText(1, 0, 0, str, fnt);

	gl.glPopMatrix();
}

the class in which this is implemented extends QGLWidget.

and so far I have come up with:


void textOut(GL gl, double x, double y, double size, String str, boolean ident)
{
    gl.glMatrixMode(GL.GL_MODELVIEW);
    gl.glPushMatrix();

    if (ident) {
        gl.glLoadIdentity();
    }
    
    gl.glColor3d(1,1,1);
    gl.glTranslated(x,y,0);
    gl.glScaled(size, size, size);      
    
    gl.glRasterPos2d(0,0);
    
    int fontId = GLUT.BITMAP_HELVETICA_10;
    
    glut.glutBitmapString(fontId, str);

    gl.glPopMatrix();
    
}

While it does the job more or less, am finding that I am getting alignment issues depending on the size of the window I am using. Any ideas as to what I should be doing?

Also are there any good routines for rendering any font in OpenGL, including True Type fonts?

Did a bit more research and turns out that Sun’s TextRenderer class is what I needed:

http://weblogs.java.net/blog/campbell/archive/2007/01/java_2d_and_jog.html

So much easier and better looking results. Now just to work out how to center the text around the specified point, for any given font and string.