espresso3d.engine.viewport.text
Class E3DVariableWidthFont

java.lang.Object
  extended byespresso3d.engine.base.E3DEngineItem
      extended byespresso3d.engine.renderer.base.E3DRenderable
          extended byespresso3d.engine.renderer.base.E3DBlendedRenderable
              extended byespresso3d.engine.renderer.base.E3DBlendedTexturedRenderable
                  extended byespresso3d.engine.viewport.text.E3DFont
                      extended byespresso3d.engine.viewport.text.E3DVariableWidthFont

public class E3DVariableWidthFont
extends espresso3d.engine.viewport.text.E3DFont

Author:
cmoxley A variable width font is a font that will scale as the window scales (NOT the viewport) That way, no matter what size the window is, the font will appear to take the same amount of space

Field Summary
 
Fields inherited from class espresso3d.engine.renderer.base.E3DBlendedRenderable
BLENDMODE_BLEND, BLENDMODE_SOLID
 
Fields inherited from class espresso3d.engine.renderer.base.E3DRenderable
RENDERMODE_SOLID, RENDERMODE_TEXTURED, RENDERMODE_WIREFRAME
 
Constructor Summary
E3DVariableWidthFont(E3DEngine engine, java.lang.String fontID, java.lang.String textureName, int numColumns, int numRows)
          Construct a variable width font.
E3DVariableWidthFont(E3DEngine engine, java.lang.String fontID, java.lang.String textureName, int numColumns, int numRows, int blendMode)
          Construct a variable width font.
 
Method Summary
 void bindSymbolToTexturePosition(char symbol, int row, int column, int symbolWidthPixels)
          This binds a symbol (a single letter, number, etc) to a certain position on this fonts texture.
 java.util.HashMap getCharSymbolMapping()
           
 java.lang.String getFontID()
           
 espresso3d.engine.viewport.text.E3DSymbol getFontSymbol(char symbol)
           
 int getGlTextureID()
           
 int getNumColumns()
           
 int getNumRows()
           
 void renderAtPosition(E3DVector3F position)
           
 void setFontID(java.lang.String fontID)
           
 void setGlTextureID(int glTextureID)
           
 void unbindSymbolFromTexture(char symbol)
           
 
Methods inherited from class espresso3d.engine.renderer.base.E3DBlendedTexturedRenderable
getRenderableOptionsKey, getTexture, setTexture
 
Methods inherited from class espresso3d.engine.renderer.base.E3DBlendedRenderable
getBlendMode, initCorrectGeometryRenderer, setBlendMode
 
Methods inherited from class espresso3d.engine.renderer.base.E3DRenderable
getRenderMode, render, setRenderMode
 
Methods inherited from class espresso3d.engine.base.E3DEngineItem
getEngine, setEngine
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

E3DVariableWidthFont

public E3DVariableWidthFont(E3DEngine engine,
                            java.lang.String fontID,
                            java.lang.String textureName,
                            int numColumns,
                            int numRows)
Construct a variable width font.

Parameters:
engine - Engine the font will reside in
fontID - Unique ID for the font
textureName - Name of the texture (loaded from a textureset) that contains all the symbols for the font
numColumns - Number of columns in the texture. This will divide the texture up evenly into numColumns and use the space in-between the columns as the place the symbols will reside
numRows - Number of rows in the texture. This will divide the texture up evenly into numRows and use the space in-between the rows as the place the symbols will reside

E3DVariableWidthFont

public E3DVariableWidthFont(E3DEngine engine,
                            java.lang.String fontID,
                            java.lang.String textureName,
                            int numColumns,
                            int numRows,
                            int blendMode)
Construct a variable width font.

Parameters:
engine - Engine the font will reside in
fontID - Unique ID for the font
textureName - Name of the texture (loaded from a textureset) that contains all the symbols for the font
numColumns - Number of columns in the texture. This will divide the texture up evenly into numColumns and use the space in-between the columns as the place the symbols will reside
numRows - Number of rows in the texture. This will divide the texture up evenly into numRows and use the space in-between the rows as the place the symbols will reside
blendMode - Blending mode of the font
Method Detail

bindSymbolToTexturePosition

public void bindSymbolToTexturePosition(char symbol,
                                        int row,
                                        int column,
                                        int symbolWidthPixels)
This binds a symbol (a single letter, number, etc) to a certain position on this fonts texture. That position will be where the engine looks on the texture when the symbol is passed into a viewport print statement. Row/Column starts in the upper left hand corner of the texture image with row=1, column=1. For example, row=1 col=1 would give you the portion of the texture starting in the upper left hand corner and extending right symbolWidths pixels and extending down symbolHeights pixels. row=1, col=2 would have an upper left corner starting at symbolWidth + 1 and extending to symbolWidth * 2 and symbolHeight

Parameters:
symbol - A single character
row - Row in the texture the character resides
column - Column in the texture the character resides
symbolWidthPixels - True number of pixels the symbol is within the row/column box. This will then be centered in the row/column to read the symbol and will then contain an exact width of the symbol so each symbol can be different widths (ie: variable width font). This symbol width can be calculated by hand, but I recommend using hte program BitmapFontBuilder (Search for it) to do this as it does it all from creating the texture to exporting the symbol widths.

getFontSymbol

public espresso3d.engine.viewport.text.E3DSymbol getFontSymbol(char symbol)

unbindSymbolFromTexture

public void unbindSymbolFromTexture(char symbol)

getFontID

public java.lang.String getFontID()

setFontID

public void setFontID(java.lang.String fontID)

getGlTextureID

public int getGlTextureID()

setGlTextureID

public void setGlTextureID(int glTextureID)

renderAtPosition

public void renderAtPosition(E3DVector3F position)
Specified by:
renderAtPosition in class E3DBlendedTexturedRenderable

getCharSymbolMapping

public java.util.HashMap getCharSymbolMapping()

getNumColumns

public int getNumColumns()

getNumRows

public int getNumRows()