- /**
- * The constructor creates a full working true-type-texture-font object.
- * Do not try to instanciate this class your self.
- * Use a implementation of IF_TTF_Loader instead.
- * You can obtain one by calling {@link TTF_Loader_Factory#newTTFLoader(int)}.
- * @param aFont - Stores all font related informations.
- * @param aFontRC - The rendering context which is needed to calculate some font properties.
- * @param aTex - The texture which is used to render the font in OpenGL.
- * @param coordVect - A vector with the texture coords of each char in the texture. The texture coords are stored in Rectangle2D instances.
- * @param aGL - An OpenGL instance which is needed to create the displaylists for the font. Use the OpenGL instance which you use for your whole application.
- */
- public TTF_Font( Font aFont, FontRenderContext aFontRC,
- Texture aTex, Vector coordVect,
- String aName, GL aGL)
- {
- font = aFont;
- fontRC = aFontRC;
- fontTex = aTex;
- coords = coordVect;
- gl = aGL;
- name = aName;
- //Create a display list for each character
- fontBase = gl.glGenLists(256);
- for (int i = 0; i<256; i++)
- {
- Rectangle2D rect = (Rectangle2D)coords.get(i);
- gl.glNewList(fontBase + i, GL.GL_COMPILE);
- gl.glBegin(GL.GL_QUADS);
- gl.glTexCoord2d(rect.getMinX(), rect.getMinY());
- gl.glVertex2i(0,0);
- gl.glTexCoord2d(rect.getMaxX(), rect.getMinY());
- gl.glVertex2i((int)rect.getWidth(),0);
- gl.glTexCoord2d(rect.getMaxX(), rect.getMaxY());
- gl.glVertex2i((int)rect.getWidth(),(int)rect.getHeight());
- gl.glTexCoord2d(rect.getMinX(), rect.getMaxY());
- gl.glVertex2i(0,(int)rect.getHeight());
- gl.glEnd();
- gl.glTranslated(rect.getWidth(),0,0); // Move to the right of the character
- gl.glEndList();
- }
- }