public class

Font

extends Object
java.lang.Object
   ↳ casmi.graphics.font.Font

Class Overview

Font class. Wraps java.awt.Font and make it easy to use.

Summary

Public Constructors
Font()
Creates a new Font object using default properties.
Font(String name)
Creates a new Font object from the specified name.
Font(String name, FontStyle style, double size)
Creates a new Font object from the specified name, style and point size.
Font(String name, String style, double size)
Creates a new Font object from the specified name, style and point size.
Font(File file)
Creates a new Font object from the specified font file.
Font(File file, FontStyle style, double size)
Creates a new Font object from the specified font file, style and point size.
Font(File file, String style, double size)
Creates a new Font object from the specified font file, style and point size.
Font(Font font)
Creates a new Font object from java.awt.Font object.
Public Methods
Font getAWTFont()
Get java.awt.Font object from this Font object.
static String[] getAvailableFontFamilyNames()
Return available fonts' name of this computer.
String getFamily()
Returns the family name of this Font.
String getFontName()
Returns the font face name of this Font.
String getName()
Returns the logical name of this Font.
String getPSName()
Returns the postscript name of this Font.
double getSize()
Returns the point size of this Font in double value.
FontStyle getStyle()
Returns the style of this Font.
void setSize(double size)
Set the new point size.
void setStyle(FontStyle style)
Set the new style.
void setStyle(String style)
Set the new style from string.
String toString()
Converts this Font object to a String representation.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public Font ()

Creates a new Font object using default properties.

public Font (String name)

Creates a new Font object from the specified name.

Parameters
name The font name.

public Font (String name, FontStyle style, double size)

Creates a new Font object from the specified name, style and point size.

Parameters
name The font name.
style The font style enum by FontStyle.
size The point size of the Font.

public Font (String name, String style, double size)

Creates a new Font object from the specified name, style and point size.

Parameters
name The font name.
style The font style.
size The point size of the Font.

public Font (File file)

Creates a new Font object from the specified font file.

Parameters
file The font file. Open Type Font(.otf) or True Type Font(.ttf) file can be used.
Throws
FontFormatException If fontFormat is not TRUETYPE_FONT or TYPE1_FONT.
IOException If the fontFile cannot be read.

public Font (File file, FontStyle style, double size)

Creates a new Font object from the specified font file, style and point size.

Parameters
file The font file. Open Type Font(.otf) or True Type Font(.ttf) file can be used.
style The font style enum by FontStyle.
size The point size of the Font.
Throws
FontFormatException If fontFormat is not TRUETYPE_FONT or TYPE1_FONT.
IOException If the fontFile cannot be read.

public Font (File file, String style, double size)

Creates a new Font object from the specified font file, style and point size.

Parameters
file The font file. Open Type Font(.otf) or True Type Font(.ttf) file can be used.
style The font style.
size The point size of the Font.
Throws
FontFormatException If fontFormat is not TRUETYPE_FONT or TYPE1_FONT.
IOException If the fontFile cannot be read.

public Font (Font font)

Creates a new Font object from java.awt.Font object.

Parameters
font java.awt.Font object.

Public Methods

public Font getAWTFont ()

Get java.awt.Font object from this Font object.

Returns
  • java.awt.Font object.

public static String[] getAvailableFontFamilyNames ()

Return available fonts' name of this computer.

Returns
  • An array of String containing font family names localized for the default locale, or a suitable alternative name if no name exists for this locale.

public String getFamily ()

Returns the family name of this Font.

Returns
  • A String that is the family name of this Font.

public String getFontName ()

Returns the font face name of this Font. For example, Helvetica Bold could be returned as a font face name. Use getFamily to get the family name of the font. Use getName to get the logical name of the font.

Returns
  • A String representing the font face name of this Font.

public String getName ()

Returns the logical name of this Font. Use getFamily to get the family name of the font. Use getFontName to get the font face name of the font.

Returns
  • A String representing the logical name of this Font.

public String getPSName ()

Returns the postscript name of this Font. Use getFamily to get the family name of the font. Use getFontName to get the font face name of the font.

Returns
  • A String representing the postscript name of this Font.

public double getSize ()

Returns the point size of this Font in double value.

Returns
  • The point size of this Font as a double value.

public FontStyle getStyle ()

Returns the style of this Font. The style can be PLAIN, BOLD, ITALIC, or BOLD+ITALIC.

Returns
  • The style of this Font.

public void setSize (double size)

Set the new point size.

Parameters
size The new point size of the Font.

public void setStyle (FontStyle style)

Set the new style.

Parameters
style The new style of this Font.

public void setStyle (String style)

Set the new style from string. This method ignores case.

Example: font.setStyle("plain");

Parameters
style The new style of this Font.

public String toString ()

Converts this Font object to a String representation.