de.matthiasmann.twl.renderer
Interface Font

All Superinterfaces:
Resource
All Known Subinterfaces:
Font2
All Known Implementing Classes:
LWJGLFont

public interface Font
extends Resource

A font rendering interface


Method Summary
 FontCache cacheMultiLineText(FontCache prevCache, java.lang.CharSequence str, int width, HAlignment align)
          Caches a text for faster drawing
 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 width)
          Computes how many glyphs of the supplied CharSequence can be display completly in the given amount of pixels.
 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'
 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 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 interface de.matthiasmann.twl.renderer.Resource
destroy
 

Method Detail

isProportional

boolean isProportional()
Returns true if the font is proportional or false if it's fixed width.

Returns:
true if the font is proportional

getBaseLine

int getBaseLine()
Returns the base line of the font measured in pixels from the top of the text bounding box

Returns:
the base line of the font measured in pixels from the top of the text bounding box

getLineHeight

int getLineHeight()
Returns the line height in pixels for this font

Returns:
the line height in pixels for this font

getSpaceWidth

int getSpaceWidth()
Returns the width of a ' '

Returns:
the width of a ' '

getEM

int getEM()
Returns the width of the letter 'M'

Returns:
the width of the letter 'M'

getEX

int getEX()
Returns the height of the letter 'x'

Returns:
the height of the letter 'x'

computeMultiLineTextWidth

int computeMultiLineTextWidth(java.lang.CharSequence str)
Computes the width in pixels of the longest text line. Lines are splitted at '\n'

Parameters:
str - the text to evaluate
Returns:
the width in pixels of the longest line

computeTextWidth

int computeTextWidth(java.lang.CharSequence str)
Computes the width in pixels of a text

Parameters:
str - the text to evaluate
Returns:
the width in pixels

computeTextWidth

int computeTextWidth(java.lang.CharSequence str,
                     int start,
                     int end)
Computes the width in pixels of a text

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

computeVisibleGlpyhs

int computeVisibleGlpyhs(java.lang.CharSequence str,
                         int start,
                         int end,
                         int width)
Computes how many glyphs of the supplied CharSequence can be display completly in the given amount of pixels.

Parameters:
str - the CharSequence
start - the start index in the CharSequence
end - the end index (exclusive) in the CharSequence
width - the number of available pixels.
Returns:
the number (relative to start) of fitting glyphs

drawMultiLineText

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'

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

drawText

int drawText(AnimationState as,
             int x,
             int y,
             java.lang.CharSequence str)
Draws a single line text

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

int drawText(AnimationState as,
             int x,
             int y,
             java.lang.CharSequence str,
             int start,
             int end)
Draws a single line text

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

cacheMultiLineText

FontCache cacheMultiLineText(FontCache prevCache,
                             java.lang.CharSequence str,
                             int width,
                             HAlignment align)
Caches a text for faster drawing

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

cacheText

FontCache cacheText(FontCache prevCache,
                    java.lang.CharSequence str)
Caches a text for faster drawing

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

FontCache cacheText(FontCache prevCache,
                    java.lang.CharSequence str,
                    int start,
                    int end)
Caches a text for faster drawing

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