Text & object coords vs. world coords

I’m working on a font engine and I’m having problems adjusting the text in the window using gluProject / gluUnProject and GetTextExtent(). For instance I want to center the text so I get the length of the text using GetTextExtent, Get the size of the window with GetWindowRect and then use gluUnProject before adjusting the X offset of the text. I can’t seem to get it to work for all font sizes. Any suggestions?