Is it possible to get the width of a character when using OpenGL bitmap fonts?
I am trying to align my bitmap font text in my OpenGL application but I can't find anything on getting the width of each character. This is my renderText function:
def renderText( self, text, fontFace, position ):
..... (omitted code to make post shorter)
glRasterPos开发者_开发知识库2i( position[0], self.windowSize[1] - position[1] )
glPushAttrib( GL_LIST_BIT )
glListBase( self.fonts[ fontFace ] - 32 )
glCallLists( text )
glPopAttrib()
......
I create the bitmap font and use glGenList to store it.
self.fonts[ fontFace ] = glGenLists( 96 )
font = win32ui.CreateFont( fontProperties )
font = hDisplayContext.SelectObject( font )
wglUseFontBitmaps( displayContext, 32, 96, self.fonts[ fontFace ] )
Anyone know if it's possible to get the character widths or even just the final rendered text's total width?
glutBitmapWidth
, glutBitmapLength
— returns the width/length of a bitmap character/string.
Python Specification:
glutBitmapWidth(font, character) -> None
glutBitmapLength(font, string) -> None
精彩评论