Index (Frames) | Index (No Frames) | Package | Package Tree | Tree
java.awt

Class Font

java.lang.Object
|
+--java.awt.Font

All Implemented Interfaces:

Serializable


public class Font

extends Object

implements Serializable

This class represents a windowing system font.

Authors:

Field Summary

static intBOLD

Constant indicating a "bold" font.
static intCENTER_BASELINE

static intHANGING_BASELINE

static intITALIC

Constant indicating an "italic" font.
static intLAYOUT_LEFT_TO_RIGHT

A flag for layoutGlyphVector, indicating that the orientation of a text run is from left to right.
static intLAYOUT_NO_LIMIT_CONTEXT

A flag for layoutGlyphVector, indicating that the text does not contain valid characters after the limit position.
static intLAYOUT_NO_START_CONTEXT

A flag for layoutGlyphVector, indicating that the text does not contain valid characters before the start position.
static intLAYOUT_RIGHT_TO_LEFT

A flag for layoutGlyphVector, indicating that the orientation of a text run is from right to left.
static intPLAIN

Constant indicating a "plain" font.
static intROMAN_BASELINE

static intTRUETYPE_FONT

Indicates to createFont that the supplied font data is in TrueType format.
java.lang.Stringname

The name of this font
floatpointSize

intsize

The font point size.
intstyle

The font style, which is a combination (by summing, not OR-ing) of the font style constants in this class.

Constructor Summary

Font(java.lang.String name, int style, int size)

Initializes a new instance of Font with the specified attributes.

Method Summary

static java.awt.Fontdecode(java.lang.String fontspec)

Creates a Font object from the specified string, which is in one of the following formats:

  • fontname-style-pointsize
  • fontname-style
  • fontname-pointsize
  • fontname

The style should be one of BOLD, ITALIC, or BOLDITALIC.

booleanequals(java.lang.Object obj)

Tests whether or not the specified object is equal to this font.
java.lang.StringgetFamily()

Returns the system specific font family name.
static java.awt.FontgetFont(java.lang.String propname, java.awt.Font defval)

Returns a Font object from the passed property name.
static java.awt.FontgetFont(java.lang.String propname)

Returns a Font object from the passed property name.
java.lang.StringgetName()

Returns the name of the font.
java.awt.peer.FontPeergetPeer()

Returns a native peer object for this font.
intgetSize()

Returns the style of the font.
floatgetSize2D()

intgetStyle()

inthashCode()

Returns a hash value for this font.
booleanisBold()

Tests whether or not this font is bold.
booleanisItalic()

Tests whether or not this font is italic.
booleanisPlain()

Tests whether or not this is a plain font.
java.lang.StringtoString()

Returns a string representation of this font.

Field Details

BOLD

public static final int BOLD

Constant indicating a "bold" font.


CENTER_BASELINE

public static final int CENTER_BASELINE


HANGING_BASELINE

public static final int HANGING_BASELINE


ITALIC

public static final int ITALIC

Constant indicating an "italic" font.


LAYOUT_LEFT_TO_RIGHT

public static final int LAYOUT_LEFT_TO_RIGHT

A flag for layoutGlyphVector, indicating that the orientation of a text run is from left to right.

Since:

LAYOUT_NO_LIMIT_CONTEXT

public static final int LAYOUT_NO_LIMIT_CONTEXT

A flag for layoutGlyphVector, indicating that the text does not contain valid characters after the limit position. If this flag is set, layoutGlyphVector does not examine the text after limit, even if this would be necessary to select the correct glyphs (e.g., for Arabic text).

Since:

LAYOUT_NO_START_CONTEXT

public static final int LAYOUT_NO_START_CONTEXT

A flag for layoutGlyphVector, indicating that the text does not contain valid characters before the start position. If this flag is set, layoutGlyphVector does not examine the text before start, even if this would be necessary to select the correct glyphs (e.g., for Arabic text).

Since:

LAYOUT_RIGHT_TO_LEFT

public static final int LAYOUT_RIGHT_TO_LEFT

A flag for layoutGlyphVector, indicating that the orientation of a text run is from right to left.

Since:

PLAIN

public static final int PLAIN

Constant indicating a "plain" font.


ROMAN_BASELINE

public static final int ROMAN_BASELINE


TRUETYPE_FONT

public static final int TRUETYPE_FONT

Indicates to createFont that the supplied font data is in TrueType format.

Specification Note: The Sun JavaDoc for J2SE 1.4 does not indicate whether this value also subsumes OpenType. OpenType is essentially the same format as TrueType, but allows to define glyph shapes in the same way as PostScript, using cubic bezier curves.

Since:

name

protected String name

The name of this font


pointSize

protected float pointSize


size

protected int size

The font point size.


style

protected int style

The font style, which is a combination (by summing, not OR-ing) of the font style constants in this class.


Constructor Details

Font

public Font(java.lang.String name, int style, int size)

Initializes a new instance of Font with the specified attributes.

Parameters:


Method Details

decode

public static Font decode(java.lang.String fontspec)

Creates a Font object from the specified string, which is in one of the following formats:

The style should be one of BOLD, ITALIC, or BOLDITALIC. The default style if none is specified is PLAIN. The default size if none is specified is 12.

Parameters:


equals

public boolean equals(java.lang.Object obj)

Tests whether or not the specified object is equal to this font. This will be true if and only if:

Parameters:

Returns:


getFamily

public String getFamily()

Returns the system specific font family name.

Returns:


getFont

public static Font getFont(java.lang.String propname)

Returns a Font object from the passed property name.

Parameters:

Returns:


getFont

public static Font getFont(java.lang.String propname, java.awt.Font defval)

Returns a Font object from the passed property name.

Parameters:

Returns:


getName

public String getName()

Returns the name of the font.

Returns:


getPeer

public FontPeer getPeer()

Returns a native peer object for this font.

Returns:


getSize

public int getSize()

Returns the style of the font.

Returns:


getSize2D

public float getSize2D()


getStyle

public int getStyle()


hashCode

public int hashCode()

Returns a hash value for this font.

Returns:


isBold

public boolean isBold()

Tests whether or not this font is bold.

Returns:


isItalic

public boolean isItalic()

Tests whether or not this font is italic.

Returns:


isPlain

public boolean isPlain()

Tests whether or not this is a plain font. This will be true if and only if neither the bold nor the italics style is set.

Returns:


toString

public String toString()

Returns a string representation of this font.

Returns: