public final class

Font

extends Object
java.lang.Object
   ↳ com.neomades.graphics.Font

Class Overview

Text Font.

Summary

Constants
int STYLE_BLACK
int STYLE_BOLD The bold style constant
int STYLE_EXTRA_BLACK
int STYLE_EXTRA_BOLD
int STYLE_EXTRA_LIGHT
int STYLE_ITALIC The italic style constant
int STYLE_LIGHT
int STYLE_MEDIUM
int STYLE_PLAIN The plain style constant
int STYLE_SEMI_BOLD
int STYLE_THIN
Fields
public static final Font DEFAULT Retrieves the default Font
Public Methods
int charWidth(char character)
Gets the advance width of the specified character in this Font.
static Font createFont(Font font, int style, int size)
Creates a new font based on the font given in parameter.
static Font createFont(Font font, int style)
Creates a new font based on the font given in parameter.
abstract String getName()
int getSize()
Returns the size of the font
int getStyle()
Returns the style of the font, which is a combination of the constants defined in this class
boolean isBold()
Returns true if the font is bold
boolean isItalic()
Returns true if the font is italic
int stringWidth(String text)
Gets the advance width of the specified text in this Font.
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final int STYLE_BLACK

Constant Value: 1024 (0x00000400)

public static final int STYLE_BOLD

The bold style constant

Constant Value: 1 (0x00000001)

public static final int STYLE_EXTRA_BLACK

Constant Value: 2048 (0x00000800)

public static final int STYLE_EXTRA_BOLD

Constant Value: 64 (0x00000040)

public static final int STYLE_EXTRA_LIGHT

Constant Value: 512 (0x00000200)

public static final int STYLE_ITALIC

The italic style constant

Constant Value: 2 (0x00000002)

public static final int STYLE_LIGHT

Constant Value: 256 (0x00000100)

public static final int STYLE_MEDIUM

Constant Value: 32 (0x00000020)

public static final int STYLE_PLAIN

The plain style constant

Constant Value: 0 (0x00000000)

public static final int STYLE_SEMI_BOLD

Constant Value: 16 (0x00000010)

public static final int STYLE_THIN

Constant Value: 128 (0x00000080)

Fields

public static final Font DEFAULT

Retrieves the default Font

Public Methods

public int charWidth (char character)

Gets the advance width of the specified character in this Font.

Parameters
character the character to be measured
Returns
  • the total advance width

public static Font createFont (Font font, int style, int size)

Creates a new font based on the font given in parameter.

Limitations

Some system fonts could not support some styles like STYLE_ITALIC. Some combinations of style may not be supported depending of the platform. For example, on iOS, the STYLE_BOLD and STYLE_ITALIC style constants can not be used together.

Three sizes will be adapted by each device because all devices have different size in pixels for theses 3 fonts.


Parameters
font the font to duplicate
style the new style of the font (a combination of the STYLE_* constants)
size the new size of the font
Returns
  • the new font

public static Font createFont (Font font, int style)

Creates a new font based on the font given in parameter.

Limitations

Some system fonts could not support some styles like STYLE_ITALIC. Some combinations of style may not be supported depending of the platform. For example, on iOS, the STYLE_BOLD and STYLE_ITALIC style constants can not be used together.

Parameters
font the font to duplicate
style the new style of the font (a combination of the STYLE_* constants)
Returns
  • the new font

public abstract String getName ()

public int getSize ()

Returns the size of the font

Returns
  • the size of the font

public int getStyle ()

Returns the style of the font, which is a combination of the constants defined in this class

Returns
  • the style of the font

public boolean isBold ()

Returns true if the font is bold

Returns
  • true if the font is bold

public boolean isItalic ()

Returns true if the font is italic

Returns
  • true if the font is italic

public int stringWidth (String text)

Gets the advance width of the specified text in this Font.

Parameters
text the String to be measured
Returns
  • the total advance width