sk.upjs.fontmapper
Class FontRenderer

java.lang.Object
  extended by sk.upjs.fontmapper.FontRenderer

 class FontRenderer
extends java.lang.Object

Font renderer. Handles rendering of font glyphs to texture pages.


Field Summary
(package private)  boolean antialiasing_
          Is font antialiasing enabled?
private  java.awt.Font font_
          Font used to draw glyphs.
(package private)  GlyphDataWriter writer_
          Used for glyph metadata output.
 
Constructor Summary
FontRenderer(java.lang.String fontName, int fontSize, int fontStyle, boolean antialiasing, GlyphDataWriter writer)
          Constructs a font renderer with specified font parameters.
 
Method Summary
 char drawFont(char min, char max, TexturePage page)
          Draw specified range of glyphs of this font to specified texture page.
private  java.awt.image.BufferedImage glyphImage_(char c, int colorMode, TexturePage page)
          Return an image with glyph of specified character.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

font_

private java.awt.Font font_
Font used to draw glyphs.


antialiasing_

boolean antialiasing_
Is font antialiasing enabled?


writer_

GlyphDataWriter writer_
Used for glyph metadata output.

Constructor Detail

FontRenderer

public FontRenderer(java.lang.String fontName,
                    int fontSize,
                    int fontStyle,
                    boolean antialiasing,
                    GlyphDataWriter writer)
             throws FontNotFoundException
Constructs a font renderer with specified font parameters.

Parameters:
fontName - Name of the font to use.
fontSize - Size of the font.
fontStyle - Style of the font.
antialiasing - Use font antialiasing?
writer - GlyphDataWriter used to output glyph metadata.
Throws:
FontNotFoundException - if the requested font does not exist.
Method Detail

drawFont

public char drawFont(char min,
                     char max,
                     TexturePage page)
              throws TextureAllocationException
Draw specified range of glyphs of this font to specified texture page.

Parameters:
min - Glyph index to start with.
max - Glyph index to end at.
page - Texture page to draw to.
Returns:
Glyph at which the drawing ended (without drawing that glyph). If the given texture page was filled, this is used to specify which glyph to start drawing to the next page.
Throws:
TextureAllocationException - if font couldn't be drawn due to a glyph larger than texture page. The last (max) glyph is not drawn.

glyphImage_

private java.awt.image.BufferedImage glyphImage_(char c,
                                                 int colorMode,
                                                 TexturePage page)
Return an image with glyph of specified character.

Parameters:
c - Character to draw.
colorMode - Color mode of the image to draw to.
page - TexturePage to get rendering context from.
Returns:
Image containing the requested glyph, or null if the glyph couldn't be drawn.