Package com.ardor3d.ui.text
Class BMFont
java.lang.Object
com.ardor3d.ui.text.BMFont
- All Implemented Interfaces:
Savable
Loads a font generated by BMFont ( @link http://www.angelcode.com/products/bmfont/ ).
- Font info file *must* be in XML format.
- The texture should be saved in 32 bit PNG format - TGA does not appear to work.
- This class only supports a single page (see BMFont documentation for details on pages)
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
static class
static class
static class
static class
class
utility to set default render states for text -
Constructor Summary
ConstructorDescriptionBMFont()
This constructor should be used when loading as SavableBMFont
(ResourceSource source, boolean useMipMaps) Reads an XML BMFont description file and loads corresponding texture. -
Method Summary
Modifier and TypeMethodDescriptionvoid
applyRenderStatesTo
(Spatial spatial, boolean useBlend) apply default render states to spatialgetChar
(int chr) Class
<?> getInfo()
int
getKerning
(int chr, int nextChr) getKerningsForCharacter
(int val) int
The average of _common.base and _common.lineHeight seems to be the best general purpose valueint
int
int
getSize()
int
int
protected void
initialize
(ResourceSource source) load the texture and create default render states.protected void
parseFontFile
(ResourceSource source) void
read
(InputCapsule capsule) void
void
void
write
(OutputCapsule capsule) void
writeXML
(OutputStream outputStream) Writes the XML for this font out to the OutputStream provided.
-
Constructor Details
-
BMFont
public BMFont()This constructor should be used when loading as Savable -
BMFont
Reads an XML BMFont description file and loads corresponding texture. Note that the TGA written by BMFont does not seem to be read properly by the Ardor3D loader. PNG works fine.- Parameters:
source
- ResourceSource describing where this font comes from.useMipMaps
- if true, use trilinear filtering with max anisotropy, else min filter is bilinear. MipMaps result in blurrier text, but less shimmering.- Throws:
IOException
- if there are any problems reading the .fnt file.
-
-
Method Details
-
setBlendStateSetter
-
setAlphaStateSetter
-
applyRenderStatesTo
apply default render states to spatial- Parameters:
spatial
- the spatialuseBlend
-true
if the blending is enabled
-
getStyleName
-
getSize
public int getSize() -
getLineHeight
public int getLineHeight()The average of _common.base and _common.lineHeight seems to be the best general purpose value- Returns:
- the line height
-
getTextureWidth
public int getTextureWidth() -
getTextureHeight
public int getTextureHeight() -
getChar
- Parameters:
chr
- ascii character code- Returns:
- character descriptor for chr. If character is not in the char set, return '?' (if '?' is not in the char set, return will be null)
-
getKerning
public int getKerning(int chr, int nextChr) - Parameters:
chr
- ascii character codenextChr
- ascii character code- Returns:
- kerning information for this character pair
-
getMaxCharAdvance
public int getMaxCharAdvance()- Returns:
- the largest xadvance in this char set
-
getOutlineWidth
public int getOutlineWidth() -
getInfo
-
writeXML
Writes the XML for this font out to the OutputStream provided.- Parameters:
outputStream
- the OutputStream to which the XML for this font will be written to- Throws:
IOException
- thrown if there is any problem writing out to the OutputStream
-
initialize
load the texture and create default render states. Only a single page is supported.- Parameters:
source
- the source of the font file- Throws:
MalformedURLException
- if the URL of the resource if malformed
-
getPageTexture
-
getMappedChars
-
getKerningsForCharacter
-
getKerningMap
-
parseFontFile
- Parameters:
source
- the resource of the font file- Throws:
IOException
- if something wrong occurs while reading the font from the file
-
write
- Specified by:
write
in interfaceSavable
- Throws:
IOException
-
read
- Specified by:
read
in interfaceSavable
- Throws:
IOException
-
getClassTag
- Specified by:
getClassTag
in interfaceSavable
-