public class Font extends Object
Fonts have a name, such as "Helvetica", a style and a point size (usually around 10). It's important to note that many mobile devices have an extremely limited number of fonts.
Modifier and Type | Field and Description |
---|---|
static int |
BOLD
A bold font style.
|
static int |
ITALIC
An italic font style.
|
static int |
OUTLINE
An outlined font style.
|
static int |
PLAIN
A plain font style.
|
static int |
STRIKETHROUGH
A strikethrough font style.
|
static int |
SUBSCRIPT
A subscript font style.
|
static int |
SUPERSCRIPT
A superscript font style.
|
static int |
SYSTEM_FONT_DEFAULT
For use with getSystemFont()
|
static int |
SYSTEM_FONT_GUI
For use with getSystemFont()
|
static int |
SYSTEM_FONT_MONOSPACED
For use with getSystemFont()
|
static int |
SYSTEM_FONT_SANS_SERIF
For use with getSystemFont()
|
static int |
SYSTEM_FONT_SERIF
For use with getSystemFont()
|
static int |
UNDERLINE
An underlined font style.
|
Constructor and Description |
---|
Font(String name,
int style,
int size)
Creates a font of the given name, style and size.
|
Modifier and Type | Method and Description |
---|---|
Font |
change(FontChange fc)
Return a new Font with the specified changes applied.
|
Font |
changeNameAndSize(String newName,
int newSize)
Change the name and/or size of a Font.
|
Font |
changeStyle(int newStyle)
Return a new Font with the same name and size, but a different style.
|
boolean |
equals(Object obj)
Returns if this object is considered equal to the other object.
|
String |
getName()
Returns the name of the font.
|
int |
getSize()
Returns the size of the font.
|
int |
getStyle()
Returns the style of the font.
|
static Font |
getSystemFont(int which)
Return, if available, the default System fonts for a named font type.
|
int |
hashCode()
Returns a hashCode for the object.
|
boolean |
isSame(Font f)
Return if this Font is the same as another.
|
static String[] |
listFonts(ISurface surface)
List the names of all the available fonts for a particular ISurface.
|
String |
toString()
Return a String representation of this object.
|
public static final int PLAIN
public static final int BOLD
public static final int ITALIC
public static final int UNDERLINE
public static final int OUTLINE
public static final int STRIKETHROUGH
public static final int SUPERSCRIPT
public static final int SUBSCRIPT
public static final int SYSTEM_FONT_DEFAULT
public static final int SYSTEM_FONT_GUI
public static final int SYSTEM_FONT_MONOSPACED
public static final int SYSTEM_FONT_SERIF
public static final int SYSTEM_FONT_SANS_SERIF
public String getName()
public int getSize()
public int getStyle()
public Font changeStyle(int newStyle)
newStyle
- The new style for the Font.public Font changeNameAndSize(String newName, int newSize)
newName
- The newName for the Font. If it is null the old name is used.newSize
- The newSize for the Font. If it is <= 0, the old size is used.public static Font getSystemFont(int which)
which
- one of the SYSTEM_FONT_XXX values.public static String[] listFonts(ISurface surface)
public String toString()
Object
public int hashCode()
Object
public boolean isSame(Font f)
f
- another Font.public boolean equals(Object obj)
Object
public Font change(FontChange fc)
fc
- a FontChange object.