|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.newdawn.slick.UnicodeFont
public class UnicodeFont
A Slick bitmap font that can display unicode glyphs from a TrueTypeFont. For efficiency, glyphs are packed on to textures. Glyphs can be loaded to the textures on the fly, when they are first needed for display. However, it is best to load the glyphs that are known to be needed at startup.
Nested Class Summary | |
---|---|
static class |
UnicodeFont.DisplayList
A simple descriptor for display lists cached within this font |
Constructor Summary | |
---|---|
UnicodeFont(java.awt.Font font)
Creates a new UnicodeFont. |
|
UnicodeFont(java.awt.Font font,
HieroSettings settings)
Creates a new UnicodeFont. |
|
UnicodeFont(java.awt.Font font,
int size,
boolean bold,
boolean italic)
Creates a new UnicodeFont. |
|
UnicodeFont(java.awt.Font font,
java.lang.String hieroFileRef)
Creates a new UnicodeFont. |
|
UnicodeFont(java.lang.String ttfFileRef,
HieroSettings settings)
Create a new unicode font based on a TTF file and a set of heiro configuration |
|
UnicodeFont(java.lang.String ttfFileRef,
int size,
boolean bold,
boolean italic)
Create a new unicode font based on a TTF file alone |
|
UnicodeFont(java.lang.String ttfFileRef,
java.lang.String hieroFileRef)
Create a new unicode font based on a TTF file |
Method Summary | |
---|---|
void |
addAsciiGlyphs()
Queues the glyphs in the ASCII character set (codepoints 32 through 255) to be loaded. |
void |
addGlyphs(int startCodePoint,
int endCodePoint)
Queues the glyphs in the specified codepoint range (inclusive) to be loaded. |
void |
addGlyphs(java.lang.String text)
Queues the glyphs in the specified text to be loaded. |
void |
addNeheGlyphs()
Queues the glyphs in the NEHE character set (codepoints 32 through 128) to be loaded. |
void |
clearGlyphs()
Clears all loaded and queued glyphs. |
void |
destroy()
Releases all resources used by this UnicodeFont. |
UnicodeFont.DisplayList |
drawDisplayList(float x,
float y,
java.lang.String text,
Color color,
int startIndex,
int endIndex)
Identical to drawString(float, float, String, Color, int, int) but returns a
DisplayList which provides access to the width and height of the text drawn. |
void |
drawString(float x,
float y,
java.lang.String text)
Draw a string to the screen |
void |
drawString(float x,
float y,
java.lang.String text,
Color col)
Draw a string to the screen |
void |
drawString(float x,
float y,
java.lang.String text,
Color color,
int startIndex,
int endIndex)
Draw part of a string to the screen. |
int |
getAscent()
Gets the distance from the baseline to the y drawing location. |
int |
getDescent()
Gets the distance from the baseline to the bottom of most alphanumeric characters with descenders. |
java.util.List |
getEffects()
Returns a list of Effect s that will be applied
to the glyphs. |
java.awt.Font |
getFont()
Returns the TrueTypeFont for this UnicodeFont. |
java.lang.String |
getFontFile()
Returns the path to the TTF file for this UnicodeFont, or null. |
int |
getGlyphPageHeight()
Returns the height of the backing textures. |
java.util.List |
getGlyphPages()
Returns the GlyphPages for this UnicodeFont. |
int |
getGlyphPageWidth()
Returns the width of the backing textures. |
int |
getHeight(java.lang.String text)
Get the height of the given string |
int |
getLeading()
Gets the extra distance between the descent of one line of text to the ascent of the next. |
int |
getLineHeight()
Returns the distance from one line of text to the next. |
int |
getPaddingAdvanceX()
Gets the additional amount to offset glyphs on the x axis. |
int |
getPaddingAdvanceY()
Gets the additional amount to offset a line of text on the y axis. |
int |
getPaddingBottom()
Returns the padding below a glyph on the GlyphPage to allow for effects to be drawn. |
int |
getPaddingLeft()
Returns the padding to the left of a glyph on the GlyphPage to allow for effects to be drawn. |
int |
getPaddingRight()
Returns the padding to the right of a glyph on the GlyphPage to allow for effects to be drawn. |
int |
getPaddingTop()
Returns the padding above a glyph on the GlyphPage to allow for effects to be drawn. |
int |
getSpaceWidth()
Returns the width of the space character. |
int |
getWidth(java.lang.String text)
Get the width of the given string |
int |
getYOffset(java.lang.String text)
Returns the distance from the y drawing location to the top most pixel of the specified text. |
boolean |
isCaching()
Returns true if this UnicodeFont caches the glyph drawing instructions to improve performance. |
boolean |
loadGlyphs()
Loads all queued glyphs to the backing textures. |
boolean |
loadGlyphs(int maxGlyphsToLoad)
Loads up to the specified number of queued glyphs to the backing textures. |
void |
setDisplayListCaching(boolean displayListCaching)
Sets if this UnicodeFont caches the glyph drawing instructions to improve performance. |
void |
setGlyphPageHeight(int glyphPageHeight)
Sets the height of the backing textures. |
void |
setGlyphPageWidth(int glyphPageWidth)
Sets the width of the backing textures. |
void |
setPaddingAdvanceX(int paddingAdvanceX)
Sets the additional amount to offset glyphs on the x axis. |
void |
setPaddingAdvanceY(int paddingAdvanceY)
Sets the additional amount to offset a line of text on the y axis. |
void |
setPaddingBottom(int paddingBottom)
Sets the padding below a glyph on the GlyphPage to allow for effects to be drawn. |
void |
setPaddingLeft(int paddingLeft)
Sets the padding to the left of a glyph on the GlyphPage to allow for effects to be drawn. |
void |
setPaddingRight(int paddingRight)
Sets the padding to the right of a glyph on the GlyphPage to allow for effects to be drawn. |
void |
setPaddingTop(int paddingTop)
Sets the padding above a glyph on the GlyphPage to allow for effects to be drawn. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public UnicodeFont(java.lang.String ttfFileRef, java.lang.String hieroFileRef) throws SlickException
ttfFileRef
- The file system or classpath location of the TrueTypeFont file.hieroFileRef
- The file system or classpath location of the Hiero settings file.
SlickException
- if the UnicodeFont could not be initialized.public UnicodeFont(java.lang.String ttfFileRef, HieroSettings settings) throws SlickException
ttfFileRef
- The file system or classpath location of the TrueTypeFont file.settings
- The settings configured via the Hiero tool
SlickException
- if the UnicodeFont could not be initialized.public UnicodeFont(java.lang.String ttfFileRef, int size, boolean bold, boolean italic) throws SlickException
ttfFileRef
- The file system or classpath location of the TrueTypeFont file.size
- The point size of the font to generatedbold
- True if the font should be rendered in bold typefaceitalic
- True if the font should be rendered in bold typeface
SlickException
- if the UnicodeFont could not be initialized.public UnicodeFont(java.awt.Font font, java.lang.String hieroFileRef) throws SlickException
font
- The AWT font to renderhieroFileRef
- The file system or classpath location of the Hiero settings file.
SlickException
- if the UnicodeFont could not be initialized.public UnicodeFont(java.awt.Font font, HieroSettings settings)
font
- The AWT font to rendersettings
- The settings configured via the Hiero toolpublic UnicodeFont(java.awt.Font font)
font
- The AWT font to renderpublic UnicodeFont(java.awt.Font font, int size, boolean bold, boolean italic)
font
- The AWT font to rendersize
- The point size of the font to generatedbold
- True if the font should be rendered in bold typefaceitalic
- True if the font should be rendered in bold typefaceMethod Detail |
---|
public void addGlyphs(int startCodePoint, int endCodePoint)
loadGlyphs()
is called.
Some characters like combining marks and non-spacing marks can only be rendered with the context of other glyphs. In this
case, use addGlyphs(String)
.
startCodePoint
- The code point of the first glyph to addendCodePoint
- The code point of the last glyph to addpublic void addGlyphs(java.lang.String text)
loadGlyphs()
is called.
text
- The text containing the glyphs to be addedpublic void addAsciiGlyphs()
loadGlyphs()
is called.
public void addNeheGlyphs()
loadGlyphs()
is called.
public boolean loadGlyphs() throws SlickException
SlickException
- if the glyphs could not be loaded.public boolean loadGlyphs(int maxGlyphsToLoad) throws SlickException
maxGlyphsToLoad
- The maximum number of glyphs to be loaded this time
SlickException
- if the glyphs could not be loaded.public void clearGlyphs()
public void destroy()
public UnicodeFont.DisplayList drawDisplayList(float x, float y, java.lang.String text, Color color, int startIndex, int endIndex)
drawString(float, float, String, Color, int, int)
but returns a
DisplayList which provides access to the width and height of the text drawn.
text
- The text to renderx
- The horizontal location to render aty
- The vertical location to render atcolor
- The colour to apply as a filter on the textstartIndex
- The start index into the string to start rendering atendIndex
- The end index into the string to render to
public void drawString(float x, float y, java.lang.String text, Color color, int startIndex, int endIndex)
Font
drawString
in interface Font
x
- The x location at which to draw the stringy
- The y location at which to draw the stringtext
- The text to be displayedcolor
- The colour to draw withstartIndex
- The index of the first character to drawendIndex
- The index of the last character from the string to drawpublic void drawString(float x, float y, java.lang.String text)
Font
drawString
in interface Font
x
- The x location at which to draw the stringy
- The y location at which to draw the stringtext
- The text to be displayedpublic void drawString(float x, float y, java.lang.String text, Color col)
Font
drawString
in interface Font
x
- The x location at which to draw the stringy
- The y location at which to draw the stringtext
- The text to be displayedcol
- The colour to draw withpublic int getSpaceWidth()
public int getWidth(java.lang.String text)
Font
getWidth
in interface Font
text
- The string to obtain the rendered with of
Font.getWidth(java.lang.String)
public int getHeight(java.lang.String text)
Font
getHeight
in interface Font
text
- The string to obtain the rendered with of
Font.getHeight(java.lang.String)
public int getYOffset(java.lang.String text)
text
- The text to analyse
public java.awt.Font getFont()
public int getPaddingTop()
public void setPaddingTop(int paddingTop)
paddingTop
- The padding at the top of the glyphs when drawnpublic int getPaddingLeft()
public void setPaddingLeft(int paddingLeft)
paddingLeft
- The padding at the left of the glyphs when drawnpublic int getPaddingBottom()
public void setPaddingBottom(int paddingBottom)
paddingBottom
- The padding at the bottom of the glyphs when drawnpublic int getPaddingRight()
public void setPaddingRight(int paddingRight)
paddingRight
- The padding at the right of the glyphs when drawnpublic int getPaddingAdvanceX()
public void setPaddingAdvanceX(int paddingAdvanceX)
paddingAdvanceX
- The padding applied for each horizontal advance (i.e. when a glyph is rendered)public int getPaddingAdvanceY()
public void setPaddingAdvanceY(int paddingAdvanceY)
paddingAdvanceY
- The padding applied for each vertical advance (i.e. when a glyph is rendered)public int getLineHeight()
setPaddingAdvanceY(int)
.
getLineHeight
in interface Font
public int getAscent()
public int getDescent()
public int getLeading()
public int getGlyphPageWidth()
public void setGlyphPageWidth(int glyphPageWidth)
glyphPageWidth
- The width of the glyph pages in this fontpublic int getGlyphPageHeight()
public void setGlyphPageHeight(int glyphPageHeight)
glyphPageHeight
- The width of the glyph pages in this fontpublic java.util.List getGlyphPages()
public java.util.List getEffects()
Effect
s that will be applied
to the glyphs.
public boolean isCaching()
public void setDisplayListCaching(boolean displayListCaching)
displayListCaching
- True if caching should be turned onpublic java.lang.String getFontFile()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |