|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object glapp.GLFont
public class GLFont
GLFont uses the Java Font class to create character sets and render text. GLFont can generate text in nearly any size, and in any font that Java supports.
Constructor Summary | |
---|---|
GLFont(java.awt.Font f)
Dynamically create a texture mapped character set with the given Font. |
|
GLFont(java.awt.Font f,
float[] fgColor,
float[] bgColor)
Create a texture mapped character set with the given Font, Text color and background color. |
Method Summary | |
---|---|
void |
buildFont(int fontTxtrHandle,
int textureSize,
int fontSize)
Build the character set display list from the given texture. |
static java.awt.image.BufferedImage |
createCharImage(java.lang.String text,
java.awt.Font font,
float[] fgColor,
float[] bgColor)
return a BufferedImage containing the given character drawn with the given font. |
java.awt.image.BufferedImage |
createFontImage(java.awt.Font font,
float[] fgColor,
float[] bgColor)
Return a BufferedImage containing 100 printable characters drawn with the given font. |
void |
destroyFont()
Clean up the allocated display lists for the character set. |
static int |
getFontSize(java.awt.Font font)
Return the maximum character size of the given Font. |
int |
getTexture()
Return the handle to the texture holding the character set. |
static int |
makeCharTexture(java.awt.Font f,
java.lang.String onechar,
float[] fgColor,
float[] bgColor)
Return a texture containing the given single character with the Courier font. |
void |
makeFont(java.awt.Font f,
float[] fgColor,
float[] bgColor)
Prepare a texture mapped character set with the given Font, text color and background color. |
int |
makeFontTexture(java.awt.Font f,
float[] fgColor,
float[] bgColor)
Return a texture containing a character set with the given Font arranged in a 10x10 grid of printable characters. |
void |
print(int x,
int y,
java.lang.String msg)
Render a text string in 2D over the scene, using the character set created by this GLFont object. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public GLFont(java.awt.Font f)
f
- Java Font objectpublic GLFont(java.awt.Font f, float[] fgColor, float[] bgColor)
f
- Java Font objectfgColor
- foreground (text) color as rgb or rgba values in range 0-1bgColor
- background color as rgb or rgba values in range 0-1 (set alpha to 0 to make transparent)Method Detail |
---|
public int getTexture()
public void makeFont(java.awt.Font f, float[] fgColor, float[] bgColor)
f
- the font to draw charactersfgColor
- foreground (text) color as rgb or rgba values in range 0-1bgColor
- background color as rgb or rgba values in range 0-1 (set alpha to 0 to make transparent)createFontImage()
,
print()
public int makeFontTexture(java.awt.Font f, float[] fgColor, float[] bgColor)
f
- the font to draw charactersfgColor
- foreground (text) color as rgb or rgba values in range 0-1bgColor
- background color as rgb or rgba values in range 0-1 (set alpha to 0 to make transparent)createFontImage()
,
print()
public static int makeCharTexture(java.awt.Font f, java.lang.String onechar, float[] fgColor, float[] bgColor)
onechar
- character to draw into texturepublic static java.awt.image.BufferedImage createCharImage(java.lang.String text, java.awt.Font font, float[] fgColor, float[] bgColor)
text
- a single character to renderfont
- the font to render withfgColor
- foreground (text) color as rgb or rgba values in range 0-1bgColor
- background color as rgb or rgba values in range 0-1 (set alpha to 0 to make transparent)
public java.awt.image.BufferedImage createFontImage(java.awt.Font font, float[] fgColor, float[] bgColor)
text
- font
- imgSize
- a power of two (32 64 256 etc)fgColor
- foreground (text) color as rgb or rgba values in range 0-1bgColor
- background color as rgb or rgba values in range 0-1 (set alpha to 0 to make transparent)
public static int getFontSize(java.awt.Font font)
Creates a BufferedImage and Graphics2D graphics context to get font sizes (is there a more efficient way to do this?).
font
- Font object describes the font to render with
public void buildFont(int fontTxtrHandle, int textureSize, int fontSize)
charSetImage
- texture image containing 100 characters in a 10x10 gridfontWidth
- how many pixels to allow per character on screendestroyFont()
public void destroyFont()
public void print(int x, int y, java.lang.String msg)
makeFont()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |