Class Font


  extended by Object
      extended by Font

public class Font
extends Object

This class is a handle to font. In order to obtain Font instances, use getFont(int, int, int) or Style.font(int).

Fonts are described in the stylesheet of a widget. A font has three basic properties: face, size and style:

These properties are given in a free list, for instance:

font-1: prop medium italic underlined

See Also:
Graphics.getFont(), Graphics.setFont(Font)

Method Summary
 int height()
          Returns the height of Font, in pixels.
 int stringWidth(String str)
          Gets the total advance width for showing the specified String in this Font.
 int substringWidth(String str, int offset, int len)
          Gets the total advance width for showing the specified substring in this Font.
 
Methods inherited from class Object
toString, equals, hashCode
 
Methods inherited from
equals, getClass, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

height

public int height()
Returns the height of Font, in pixels.


stringWidth

public int stringWidth(String str)
Gets the total advance width for showing the specified String in this Font. The advance width is the horizontal distance that would be occupied if str were to be drawn using this Font, including inter-character spacing following str necessary for proper positioning of subsequent text.

Parameters:
str - the String to be measured
Returns:
the total advance width

substringWidth

public int substringWidth(String str,
                          int offset,
                          int len)
Gets the total advance width for showing the specified substring in this Font. The advance width is the horizontal distance that would be occupied if the substring were to be drawn using this Font, including inter-character spacing following the substring necessary for proper positioning of subsequent text.

The offset and len parameters must specify a valid range of characters within str. The offset parameter must be within the range [0..(str.length())], inclusive. The len parameter must be a non-negative integer such that (offset + len) <= str.length().

Parameters:
str - the String to be measured
offset - zero-based index of first character in the substring
len - length of the substring
Returns:
the total advance width