de.matthiasmann.twl.renderer.lwjgl
Class LWJGLFont

java.lang.Object
  extended by de.matthiasmann.twl.renderer.lwjgl.LWJGLFont
All Implemented Interfaces:
Font, Font2, Resource

public class LWJGLFont
extends java.lang.Object
implements Font, Font2


Method Summary
 AttributedStringFontCache cacheMultiLineText(AttributedStringFontCache prevCache, AttributedString attributedString)
           
 AttributedStringFontCache cacheMultiLineText(AttributedStringFontCache prevCache, AttributedString attributedString, int start, int end)
           
 FontCache cacheMultiLineText(FontCache prevCache, java.lang.CharSequence str, int width, HAlignment align)
          Caches a text for faster drawing
 AttributedStringFontCache cacheText(AttributedStringFontCache prevCache, AttributedString attributedString)
           
 AttributedStringFontCache cacheText(AttributedStringFontCache prevCache, AttributedString attributedString, int start, int end)
           
 FontCache cacheText(FontCache prevCache, java.lang.CharSequence str)
          Caches a text for faster drawing
 FontCache cacheText(FontCache prevCache, java.lang.CharSequence str, int start, int end)
          Caches a text for faster drawing
 int computeMultiLineTextWidth(java.lang.CharSequence str)
          Computes the width in pixels of the longest text line.
 int computeTextWidth(java.lang.CharSequence str)
          Computes the width in pixels of a text
 int computeTextWidth(java.lang.CharSequence str, int start, int end)
          Computes the width in pixels of a text
 int computeVisibleGlpyhs(java.lang.CharSequence str, int start, int end, int availWidth)
          Computes how many glyphs of the supplied CharSequence can be display completly in the given amount of pixels.
 void destroy()
          After destroying a resurce it is no longer useable.
 int drawMultiLineText(AnimationState as, int x, int y, java.lang.CharSequence str, int width, HAlignment align)
          Draws multi line text - lines are splitted at '\n'
 void drawMultiLineText(int x, int y, AttributedString attributedString)
           
 void drawMultiLineText(int x, int y, AttributedString attributedString, int start, int end)
           
 int drawText(AnimationState as, int x, int y, java.lang.CharSequence str)
          Draws a single line text
 int drawText(AnimationState as, int x, int y, java.lang.CharSequence str, int start, int end)
          Draws a single line text
 int drawText(int x, int y, AttributedString attributedString)
           
 int drawText(int x, int y, AttributedString attributedString, int start, int end)
           
 int getBaseLine()
          Returns the base line of the font measured in pixels from the top of the text bounding box
 int getEM()
          Returns the width of the letter 'M'
 int getEX()
          Returns the height of the letter 'x'
 int getLineHeight()
          Returns the line height in pixels for this font
 int getSpaceWidth()
          Returns the width of a ' '
 boolean isProportional()
          Returns true if the font is proportional or false if it's fixed width.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

destroy

public void destroy()
Description copied from interface: Resource
After destroying a resurce it is no longer useable.

Specified by:
destroy in interface Resource

isProportional

public boolean isProportional()
Description copied from interface: Font
Returns true if the font is proportional or false if it's fixed width.

Specified by:
isProportional in interface Font
Returns:
true if the font is proportional

getSpaceWidth

public int getSpaceWidth()
Description copied from interface: Font
Returns the width of a ' '

Specified by:
getSpaceWidth in interface Font
Returns:
the width of a ' '

getLineHeight

public int getLineHeight()
Description copied from interface: Font
Returns the line height in pixels for this font

Specified by:
getLineHeight in interface Font
Returns:
the line height in pixels for this font

getBaseLine

public int getBaseLine()
Description copied from interface: Font
Returns the base line of the font measured in pixels from the top of the text bounding box

Specified by:
getBaseLine in interface Font
Returns:
the base line of the font measured in pixels from the top of the text bounding box

getEM

public int getEM()
Description copied from interface: Font
Returns the width of the letter 'M'

Specified by:
getEM in interface Font
Returns:
the width of the letter 'M'

getEX

public int getEX()
Description copied from interface: Font
Returns the height of the letter 'x'

Specified by:
getEX in interface Font
Returns:
the height of the letter 'x'

drawText

public int drawText(AnimationState as,
                    int x,
                    int y,
                    java.lang.CharSequence str)
Description copied from interface: Font
Draws a single line text

Specified by:
drawText in interface Font
Parameters:
as - A time source for animation - may be null
x - left coordinate of the text block
y - top coordinate of the text block
str - the text to draw
Returns:
the width in pixels of the text

drawText

public int drawText(AnimationState as,
                    int x,
                    int y,
                    java.lang.CharSequence str,
                    int start,
                    int end)
Description copied from interface: Font
Draws a single line text

Specified by:
drawText in interface Font
Parameters:
as - A time source for animation - may be null
x - left coordinate of the text block
y - top coordinate of the text block
str - the text to draw
start - index of first character to draw in str
end - index after last character to draw in str
Returns:
the width in pixels of the text

drawMultiLineText

public int drawMultiLineText(AnimationState as,
                             int x,
                             int y,
                             java.lang.CharSequence str,
                             int width,
                             HAlignment align)
Description copied from interface: Font
Draws multi line text - lines are splitted at '\n'

Specified by:
drawMultiLineText in interface Font
Parameters:
as - A time source for animation - may be null
x - left coordinate of the text block
y - top coordinate of the text block
str - the text to draw
width - the width of the text block
align - horizontal alignment for shorter lines
Returns:
the height in pixels of the multi line text

computeVisibleGlpyhs

public int computeVisibleGlpyhs(java.lang.CharSequence str,
                                int start,
                                int end,
                                int availWidth)
Description copied from interface: Font
Computes how many glyphs of the supplied CharSequence can be display completly in the given amount of pixels.

Specified by:
computeVisibleGlpyhs in interface Font
Parameters:
str - the CharSequence
start - the start index in the CharSequence
end - the end index (exclusive) in the CharSequence
availWidth - the number of available pixels.
Returns:
the number (relative to start) of fitting glyphs

computeTextWidth

public int computeTextWidth(java.lang.CharSequence str)
Description copied from interface: Font
Computes the width in pixels of a text

Specified by:
computeTextWidth in interface Font
Parameters:
str - the text to evaluate
Returns:
the width in pixels

computeTextWidth

public int computeTextWidth(java.lang.CharSequence str,
                            int start,
                            int end)
Description copied from interface: Font
Computes the width in pixels of a text

Specified by:
computeTextWidth in interface Font
Parameters:
str - the text to evaluate
start - index of first character in str
end - index after last character in str
Returns:
the width in pixels

computeMultiLineTextWidth

public int computeMultiLineTextWidth(java.lang.CharSequence str)
Description copied from interface: Font
Computes the width in pixels of the longest text line. Lines are splitted at '\n'

Specified by:
computeMultiLineTextWidth in interface Font
Parameters:
str - the text to evaluate
Returns:
the width in pixels of the longest line

cacheText

public FontCache cacheText(FontCache prevCache,
                           java.lang.CharSequence str)
Description copied from interface: Font
Caches a text for faster drawing

Specified by:
cacheText in interface Font
Parameters:
prevCache - the previous cached text or null
str - the text to cache
Returns:
A cache object or null if caching was not possible

cacheText

public FontCache cacheText(FontCache prevCache,
                           java.lang.CharSequence str,
                           int start,
                           int end)
Description copied from interface: Font
Caches a text for faster drawing

Specified by:
cacheText in interface Font
Parameters:
prevCache - the previous cached text or null
str - the text to cache
start - index of first character to draw in str
end - index after last character to draw in str
Returns:
A cache object or null if caching was not possible

cacheMultiLineText

public FontCache cacheMultiLineText(FontCache prevCache,
                                    java.lang.CharSequence str,
                                    int width,
                                    HAlignment align)
Description copied from interface: Font
Caches a text for faster drawing

Specified by:
cacheMultiLineText in interface Font
Parameters:
prevCache - the previous cached text or null
str - the text to cache
width - the width of the text block
align - horizontal alignment for shorter lines
Returns:
A cache object or null if caching was not possible

drawText

public int drawText(int x,
                    int y,
                    AttributedString attributedString)
Specified by:
drawText in interface Font2

drawText

public int drawText(int x,
                    int y,
                    AttributedString attributedString,
                    int start,
                    int end)
Specified by:
drawText in interface Font2

drawMultiLineText

public void drawMultiLineText(int x,
                              int y,
                              AttributedString attributedString)
Specified by:
drawMultiLineText in interface Font2

drawMultiLineText

public void drawMultiLineText(int x,
                              int y,
                              AttributedString attributedString,
                              int start,
                              int end)
Specified by:
drawMultiLineText in interface Font2

cacheText

public AttributedStringFontCache cacheText(AttributedStringFontCache prevCache,
                                           AttributedString attributedString)
Specified by:
cacheText in interface Font2

cacheText

public AttributedStringFontCache cacheText(AttributedStringFontCache prevCache,
                                           AttributedString attributedString,
                                           int start,
                                           int end)
Specified by:
cacheText in interface Font2

cacheMultiLineText

public AttributedStringFontCache cacheMultiLineText(AttributedStringFontCache prevCache,
                                                    AttributedString attributedString)
Specified by:
cacheMultiLineText in interface Font2

cacheMultiLineText

public AttributedStringFontCache cacheMultiLineText(AttributedStringFontCache prevCache,
                                                    AttributedString attributedString,
                                                    int start,
                                                    int end)
Specified by:
cacheMultiLineText in interface Font2