java.awt
Class Font

java.lang.Object
  |
  +--java.awt.Font
All Implemented Interfaces:
Serializable

public class Font
extends Object
implements Serializable

Safe:

See Also:
Serialized Form

Field Summary
static int BOLD
          Enabled: The bold style constant.
private static double[] cachedMat
          get the transform matrix for this font.
private static java.lang.ref.SoftReference cacheRef
           
private  int canRotate
           
static int CENTER_BASELINE
          Enabled: The baseline used in ideographic scripts like Chinese, Japanese, and Korean when laying out text.
private  boolean createdFont
           
private static Map EMPTY_MAP
           
private  int fontSerializedDataVersion
          The Font Serializable Data Form.
private  Hashtable fRequestedAttributes
          A map of font attributes available in this font.
static int HANGING_BASELINE
          Enabled: The baseline used in Devanigiri and similar scripts when laying out text.
private static java.awt.font.TransformAttribute IDENT_TX_ATTRIBUTE
           
static int ITALIC
          Enabled: The italicized style constant.
static int LAYOUT_LEFT_TO_RIGHT
          Enabled: A flag to layoutGlyphVector indicating that text is left-to-right as determined by Bidi analysis.
static int LAYOUT_NO_LIMIT_CONTEXT
          Enabled: A flag to layoutGlyphVector indicating that text in the char array after the indicated limit should not be examined.
static int LAYOUT_NO_START_CONTEXT
          Enabled: A flag to layoutGlyphVector indicating that text in the char array before the indicated start should not be examined.
static int LAYOUT_RIGHT_TO_LEFT
          Enabled: A flag to layoutGlyphVector indicating that text is right-to-left as determined by Bidi analysis.
private  double[] matrix
           
private  int missingGlyph
           
protected  String name
          The logical name of this Font, as passed to the constructor.
private  boolean nonIdentityTx
           
private  int numGlyphs
           
private  long pData
           
private  java.awt.peer.FontPeer peer
          The platform specific font information.
static int PLAIN
          Enabled: The plain style constant.
private  long pNativeFont
           
protected  float pointSize
          The point size of this Font in float.
static int ROMAN_BASELINE
          Enabled: The baseline used in most Roman scripts when laying out text.
private static long serialVersionUID
           
protected  int size
          The point size of this Font, rounded to integer.
protected  int style
          The style of this Font, as passed to the constructor.
static int TRUETYPE_FONT
          Enabled: Create a Font of type TRUETYPE.
 
Constructor Summary
  Font(Map attributes)
          Enabled: Creates a new Font with the specified attributes.
private Font(Map attributes, boolean created)
           
private Font(String name, int style, float sizePts, boolean created)
           
  Font(String name, int style, int size)
          Enabled: Creates a new Font from the specified name, style and point size.
private Font(String name, int style, int size, boolean created)
           
 
Method Summary
private static void applySize(float size, Map attributes)
           
private static void applyStyle(int style, Map attributes)
           
private static void applyTransform(java.awt.geom.AffineTransform trans, Map attributes)
           
 boolean canDisplay(char c)
          Enabled: Checks if this Font has a glyph for the specified character.
 int canDisplayUpTo(char[] text, int start, int limit)
          Enabled: Indicates whether or not this Font can display the characters in the specified text starting at start and ending at limit.
 int canDisplayUpTo(java.text.CharacterIterator iter, int start, int limit)
          Enabled: Indicates whether or not this Font can display the specified String.
 int canDisplayUpTo(String str)
          Enabled: Indicates whether or not this Font can display a specified String.
static Font createFont(int fontFormat, InputStream fontStream)
          Enabled: Returns a new Font with the specified font type and input data.
 java.awt.font.GlyphVector createGlyphVector(java.awt.font.FontRenderContext frc, char[] chars)
          Enabled: Creates a GlyphVector by mapping characters to glyphs one-to-one based on the Unicode cmap in this Font.
 java.awt.font.GlyphVector createGlyphVector(java.awt.font.FontRenderContext frc, java.text.CharacterIterator ci)
          Enabled: Creates a GlyphVector by mapping the specified characters to glyphs one-to-one based on the Unicode cmap in this Font.
 java.awt.font.GlyphVector createGlyphVector(java.awt.font.FontRenderContext frc, int[] glyphCodes)
          Enabled: Creates a GlyphVector by mapping characters to glyphs one-to-one based on the Unicode cmap in this Font.
 java.awt.font.GlyphVector createGlyphVector(java.awt.font.FontRenderContext frc, String str)
          Enabled: Creates a GlyphVector by mapping characters to glyphs one-to-one based on the Unicode cmap in this Font.
static Font decode(String str)
          Enabled: Returns the Font that the str argument describes.
private  java.awt.Font.FontLineMetrics defaultLineMetrics(java.awt.font.FontRenderContext frc)
           
 Font deriveFont(java.awt.geom.AffineTransform trans)
          Enabled: Creates a new Font object by replicating the current Font object and applying a new transform to it.
 Font deriveFont(float size)
          Enabled: Creates a new Font object by replicating the current Font object and applying a new size to it.
 Font deriveFont(int style)
          Enabled: Creates a new Font object by replicating the current Font object and applying a new style to it.
 Font deriveFont(int style, java.awt.geom.AffineTransform trans)
          Enabled: Creates a new Font object by replicating this Font object and applying a new style and transform.
 Font deriveFont(int style, float size)
          Enabled: Creates a new Font object by replicating this Font object and applying a new style and size.
 Font deriveFont(Map attributes)
          Enabled: Creates a new Font object by replicating the current Font object and applying a new set of font attributes to it.
 boolean equals(Object obj)
          Suppressed: Compares this Font object to the specified Object.
protected  void finalize()
          Disposes the native Font object.
private static Font get(java.awt.Font.Key key)
           
 Map getAttributes()
          Enabled: Returns a map of font attributes available in this Font.
 java.text.AttributedCharacterIterator.Attribute[] getAvailableAttributes()
          Enabled: Returns the keys of all the attributes supported by this Font.
 byte getBaselineFor(char c)
          Enabled: Returns the baseline appropriate for displaying this character.
(package private)  String getFamily_NoClientCode()
           
 String getFamily()
          Enabled: Returns the family name of this Font.
 String getFamily(Locale l)
          Enabled: Returns the family name of this Font, localized for the specified locale.
static Font getFont(Map attributes)
          Enabled: Returns a Font appropriate to this attribute set.
static Font getFont(String nm)
          Enabled: Returns a Font object from the system properties list.
static Font getFont(String nm, Font font)
          Enabled: Gets the specified Font from the system properties list.
 String getFontName()
          Enabled: Returns the font face name of this Font.
 String getFontName(Locale l)
          Enabled: Returns the font face name of the Font, localized for the specified locale.
 float getItalicAngle()
          Enabled: Returns the italic angle of this Font.
 java.awt.font.LineMetrics getLineMetrics(char[] chars, int beginIndex, int limit, java.awt.font.FontRenderContext frc)
          Enabled: Returns a LineMetrics object created with the specified arguments.
 java.awt.font.LineMetrics getLineMetrics(java.text.CharacterIterator ci, int beginIndex, int limit, java.awt.font.FontRenderContext frc)
          Enabled: Returns a LineMetrics object created with the specified arguments.
 java.awt.font.LineMetrics getLineMetrics(String str, java.awt.font.FontRenderContext frc)
          Enabled: Returns a LineMetrics object created with the specified String and FontRenderContext.
 java.awt.font.LineMetrics getLineMetrics(String str, int beginIndex, int limit, java.awt.font.FontRenderContext frc)
          Enabled: Returns a LineMetrics object created with the specified arguments.
private  double[] getMatrix()
           
 java.awt.geom.Rectangle2D getMaxCharBounds(java.awt.font.FontRenderContext frc)
          Enabled: Returns the bounds for the character with the maximum bounds as defined in the specified FontRenderContext.
 int getMissingGlyphCode()
          Enabled: Returns the glyphCode which is used when this Font does not have a glyph for a specified unicode.
 String getName()
          Enabled: Returns the logical name of this Font.
 int getNumGlyphs()
          Enabled: Returns the number of glyphs in this Font.
(package private)  java.awt.peer.FontPeer getPeer_NoClientCode()
           
 java.awt.peer.FontPeer getPeer()
          Deprecated. Font rendering is now platform independent.
 String getPSName()
          Enabled: Returns the postscript name of this Font.
 int getSize()
          Enabled: Returns the point size of this Font, rounded to an integer.
 float getSize2D()
          Enabled: Returns the point size of this Font in float value.
 java.awt.geom.Rectangle2D getStringBounds(char[] chars, int beginIndex, int limit, java.awt.font.FontRenderContext frc)
          Enabled: Returns the logical bounds of the specified array of characters in the specified FontRenderContext.
 java.awt.geom.Rectangle2D getStringBounds(java.text.CharacterIterator ci, int beginIndex, int limit, java.awt.font.FontRenderContext frc)
          Enabled: Returns the logical bounds of the characters indexed in the specified CharacterIterator in the specified FontRenderContext.
 java.awt.geom.Rectangle2D getStringBounds(String str, java.awt.font.FontRenderContext frc)
          Enabled: Returns the logical bounds of the specified String in the specified FontRenderContext.
 java.awt.geom.Rectangle2D getStringBounds(String str, int beginIndex, int limit, java.awt.font.FontRenderContext frc)
          Enabled: Returns the logical bounds of the specified String in the specified FontRenderContext.
 int getStyle()
          Enabled: Returns the style of this Font.
 java.awt.geom.AffineTransform getTransform()
          Enabled: Returns a copy of the transform associated with this Font.
 int hashCode()
          Suppressed: Returns a hashcode for this Font.
 boolean hasUniformLineMetrics()
          Enabled: Checks whether or not this Font has uniform line metrics.
private  void initFromMap(Map attributes)
           
private  void initializeFont(Hashtable attributes)
           
private static void initIDs()
           
 boolean isBold()
          Enabled: Indicates whether or not this Font object's style is BOLD.
 boolean isItalic()
          Enabled: Indicates whether or not this Font object's style is ITALIC.
 boolean isPlain()
          Enabled: Indicates whether or not this Font object's style is PLAIN.
 boolean isTransformed()
          Enabled: Indicates whether or not this Font object has a transform that affects its size in addition to the Size attribute.
 java.awt.font.GlyphVector layoutGlyphVector(java.awt.font.FontRenderContext frc, char[] text, int start, int limit, int flags)
          Suppressed: Returns a new GlyphVector object, performing full layout of the text if possible.
private  void pDispose()
           
private  void readObject(ObjectInputStream s)
          Reads the ObjectInputStream.
 String toString()
          Suppressed: Converts this Font object to a String representation.
private  void writeObject(ObjectOutputStream s)
          Writes default serializable fields to a stream.
 
Methods inherited from class java.lang.Object
clone, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

fRequestedAttributes

private Hashtable fRequestedAttributes
A map of font attributes available in this font. Attributes include things like ligatures and glyph substitution.

See Also:
getAttributes()

EMPTY_MAP

private static final Map EMPTY_MAP

IDENT_TX_ATTRIBUTE

private static final java.awt.font.TransformAttribute IDENT_TX_ATTRIBUTE

PLAIN

public static final int PLAIN
Enabled: The plain style constant.


BOLD

public static final int BOLD
Enabled: The bold style constant. This can be combined with the other style constants (except PLAIN) for mixed styles.


ITALIC

public static final int ITALIC
Enabled: The italicized style constant. This can be combined with the other style constants (except PLAIN) for mixed styles.


ROMAN_BASELINE

public static final int ROMAN_BASELINE
Enabled: The baseline used in most Roman scripts when laying out text.


CENTER_BASELINE

public static final int CENTER_BASELINE
Enabled: The baseline used in ideographic scripts like Chinese, Japanese, and Korean when laying out text.


HANGING_BASELINE

public static final int HANGING_BASELINE
Enabled: The baseline used in Devanigiri and similar scripts when laying out text.


TRUETYPE_FONT

public static final int TRUETYPE_FONT
Enabled: Create a Font of type TRUETYPE. In future other types may be added to support other font types.


name

protected String name
The logical name of this Font, as passed to the constructor.

Since:
JDK1.0
See Also:
getName()

style

protected int style
The style of this Font, as passed to the constructor. This style can be PLAIN, BOLD, ITALIC, or BOLD+ITALIC.

Since:
JDK1.0
See Also:
getStyle()

size

protected int size
The point size of this Font, rounded to integer.

Since:
JDK1.0
See Also:
getSize()

pointSize

protected float pointSize
The point size of this Font in float.

See Also:
getSize(), getSize2D()

peer

private transient java.awt.peer.FontPeer peer
The platform specific font information.


pData

private transient long pData

pNativeFont

private transient long pNativeFont

createdFont

private transient boolean createdFont

numGlyphs

private transient int numGlyphs

missingGlyph

private transient int missingGlyph

canRotate

private transient int canRotate

matrix

private transient double[] matrix

nonIdentityTx

private transient boolean nonIdentityTx

serialVersionUID

private static final long serialVersionUID

cacheRef

private static java.lang.ref.SoftReference cacheRef

fontSerializedDataVersion

private int fontSerializedDataVersion
The Font Serializable Data Form.


cachedMat

private static double[] cachedMat
get the transform matrix for this font.


LAYOUT_LEFT_TO_RIGHT

public static final int LAYOUT_LEFT_TO_RIGHT
Enabled: A flag to layoutGlyphVector indicating that text is left-to-right as determined by Bidi analysis.


LAYOUT_RIGHT_TO_LEFT

public static final int LAYOUT_RIGHT_TO_LEFT
Enabled: A flag to layoutGlyphVector indicating that text is right-to-left as determined by Bidi analysis.


LAYOUT_NO_START_CONTEXT

public static final int LAYOUT_NO_START_CONTEXT
Enabled: A flag to layoutGlyphVector indicating that text in the char array before the indicated start should not be examined.


LAYOUT_NO_LIMIT_CONTEXT

public static final int LAYOUT_NO_LIMIT_CONTEXT
Enabled: A flag to layoutGlyphVector indicating that text in the char array after the indicated limit should not be examined.

Constructor Detail

Font

public Font(String name,
            int style,
            int size)
Enabled: Creates a new Font from the specified name, style and point size.

Parameters:
name - the font name. This can be a logical font name or a font face name. A logical name must be either: Dialog, DialogInput, Monospaced, Serif, or SansSerif. If name is null, the name of the new Font is set to the name "Default".
style - the style constant for the Font The style argument is an integer bitmask that may be PLAIN, or a bitwise union of BOLD and/or ITALIC (for example, ITALIC or BOLD|ITALIC). If the style argument does not conform to one of the expected integer bitmasks then the style is set to PLAIN.
size - the point size of the Font
Since:
JDK1.0
See Also:
GraphicsEnvironment.getAllFonts(), GraphicsEnvironment.getAvailableFontFamilyNames()

Font

private Font(String name,
             int style,
             int size,
             boolean created)

Font

private Font(String name,
             int style,
             float sizePts,
             boolean created)

Font

public Font(Map attributes)
Enabled: Creates a new Font with the specified attributes. This Font only recognizes keys defined in TextAttribute as attributes. If attributes is null, a new Font is initialized with default attributes.

Parameters:
attributes - the attributes to assign to the new Font, or null

Font

private Font(Map attributes,
             boolean created)
Method Detail

getPeer

public java.awt.peer.FontPeer getPeer()
Deprecated. Font rendering is now platform independent.

Enabled: Gets the peer of this Font.

Returns:
the peer of the Font.
Since:
JDK1.1

getPeer_NoClientCode

final java.awt.peer.FontPeer getPeer_NoClientCode()

initializeFont

private void initializeFont(Hashtable attributes)

initFromMap

private void initFromMap(Map attributes)

getFont

public static Font getFont(Map attributes)
Enabled: Returns a Font appropriate to this attribute set.

Parameters:
attributes - the attributes to assign to the new Font
Returns:
a new Font created with the specified attributes
Since:
1.2
See Also:
java.awt.font.TextAttribute

get

private static Font get(java.awt.Font.Key key)

createFont

public static Font createFont(int fontFormat,
                              InputStream fontStream)
                       throws FontFormatException,
                              IOException
Enabled: Returns a new Font with the specified font type and input data. The new Font is created with a point size of 1 and style PLAIN. This base font can then be used with the deriveFont methods in this class to derive new Font objects with varying sizes, styles, transforms and font features. This method does not close the InputStream.

Parameters:
fontFormat - the type of the Font, which is TRUETYPE_FONT if a TrueType is desired. Other types might be provided in the future.
fontStream - an InputStream object representing the input data for the font.
Returns:
a new Font created with the specified font type.
Throws:
IllegalArgumentException - if fontType is not TRUETYPE_FONT
FontFormatException - if the fontStream data does not contain the required Truetype font tables.
IOException - if the fontStream cannot be completely read.
Since:
1.3

getTransform

public java.awt.geom.AffineTransform getTransform()
Enabled: Returns a copy of the transform associated with this Font.

Returns:
an AffineTransform object representing the transform attribute of this Font object.

getFamily

public String getFamily()
Enabled: Returns the family name of this Font.

The family name of a font is font specific. Two fonts such as Helvetica Italic and Helvetica Bold have the same family name, Helvetica, whereas their font face names are Helvetica Bold and Helvetica Italic. The list of available family names may be obtained by using the GraphicsEnvironment.getAvailableFontFamilyNames() method.

Use getName to get the logical name of the font. Use getFontName to get the font face name of the font.

Returns:
a String that is the family name of this Font.
Since:
JDK1.1
See Also:
getName(), getFontName()

getFamily_NoClientCode

final String getFamily_NoClientCode()

getFamily

public String getFamily(Locale l)
Enabled: Returns the family name of this Font, localized for the specified locale.

The family name of a font is font specific. Two fonts such as Helvetica Italic and Helvetica Bold have the same family name, Helvetica, whereas their font face names are Helvetica Bold and Helvetica Italic. The list of available family names may be obtained by using the GraphicsEnvironment.getAvailableFontFamilyNames() method.

Use getFontName to get the font face name of the font.

Parameters:
l - locale for which to get the family name
Returns:
a String representing the family name of the font, localized for the specified locale.
Since:
1.2
See Also:
getFontName(), java.util.Locale

getPSName

public String getPSName()
Enabled: 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.
Since:
1.2

getName

public String getName()
Enabled: 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.
Since:
JDK1.0
See Also:
getFamily(), getFontName()

getFontName

public String getFontName()
Enabled: 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.
Since:
1.2
See Also:
getFamily(), getName()

getFontName

public String getFontName(Locale l)
Enabled: Returns the font face name of the Font, localized for the specified locale. For example, Helvetica Fett could be returned as the font face name. Use getFamily to get the family name of the font.

Parameters:
l - a locale for which to get the font face name
Returns:
a String representing the font face name, localized for the specified locale.
See Also:
getFamily(), java.util.Locale

getStyle

public int getStyle()
Enabled: Returns the style of this Font. The style can be PLAIN, BOLD, ITALIC, or BOLD+ITALIC.

Returns:
the style of this Font
Since:
JDK1.0
See Also:
isPlain(), isBold(), isItalic()

getSize

public int getSize()
Enabled: Returns the point size of this Font, rounded to an integer. Most users are familiar with the idea of using point size to specify the size of glyphs in a font. This point size defines a measurement between the baseline of one line to the baseline of the following line in a single spaced text document. The point size is based on typographic points, approximately 1/72 of an inch.

The Java(tm)2D API adopts the convention that one point is equivalent to one unit in user coordinates. When using a normalized transform for converting user space coordinates to device space coordinates 72 user space units equal 1 inch in device space. In this case one point is 1/72 of an inch.

Returns:
the point size of this Font in 1/72 of an inch units.
Since:
JDK1.0
See Also:
getSize2D(), GraphicsConfiguration.getDefaultTransform(), GraphicsConfiguration.getNormalizingTransform()

getSize2D

public float getSize2D()
Enabled: Returns the point size of this Font in float value.

Returns:
the point size of this Font as a float value.
Since:
1.2
See Also:
getSize()

isPlain

public boolean isPlain()
Enabled: Indicates whether or not this Font object's style is PLAIN.

Returns:
true if this Font has a PLAIN sytle; false otherwise.
Since:
JDK1.0
See Also:
java.awt.Font#getStyle

isBold

public boolean isBold()
Enabled: Indicates whether or not this Font object's style is BOLD.

Returns:
true if this Font object's style is BOLD; false otherwise.
Since:
JDK1.0
See Also:
java.awt.Font#getStyle

isItalic

public boolean isItalic()
Enabled: Indicates whether or not this Font object's style is ITALIC.

Returns:
true if this Font object's style is ITALIC; false otherwise.
Since:
JDK1.0
See Also:
java.awt.Font#getStyle

isTransformed

public boolean isTransformed()
Enabled: Indicates whether or not this Font object has a transform that affects its size in addition to the Size attribute.

Returns:
true if this Font object has a non-identity AffineTransform attribute. false otherwise.
Since:
1.4
See Also:
java.awt.Font#getTransform

getFont

public static Font getFont(String nm)
Enabled: Returns a Font object from the system properties list.

Parameters:
nm - the property name
Returns:
a Font object that the property name describes.
Since:
1.2

decode

public static Font decode(String str)
Enabled: Returns the Font that the str argument describes. To ensure that this method returns the desired Font, format the str parameter in one of two ways:

"fontfamilyname-style-pointsize" or
"fontfamilyname style pointsize"

in which style is one of the three case-insensitive strings: "BOLD", "BOLDITALIC", or "ITALIC", and pointsize is a decimal representation of the point size. For example, if you want a font that is Arial, bold, and a point size of 18, you would call this method with: "Arial-BOLD-18".

The default size is 12 and the default style is PLAIN. If you don't specify a valid size, the returned Font has a size of 12. If you don't specify a valid style, the returned Font has a style of PLAIN. If you do not provide a valid font family name in the str argument, this method still returns a valid font with a family name of "dialog". To determine what font family names are available on your system, use the GraphicsEnvironment.getAvailableFontFamilyNames() method. If str is null, a new Font is returned with the family name "dialog", a size of 12 and a PLAIN style. If str is null, a new Font is returned with the name "dialog", a size of 12 and a PLAIN style.

Parameters:
str - the name of the font, or null
Returns:
the Font object that str describes, or a new default Font if str is null.
Since:
JDK1.1
See Also:
getFamily()

getFont

public static Font getFont(String nm,
                           Font font)
Enabled: Gets the specified Font from the system properties list. As in the getProperty method of System, the first argument is treated as the name of a system property to be obtained. The String value of this property is then interpreted as a Font object.

The property value should be one of the following forms:

where style is one of the three case-insensitive strings "BOLD", "BOLDITALIC", or "ITALIC", and point size is a decimal representation of the point size.

The default style is PLAIN. The default point size is 12.

If the specified property is not found, the font argument is returned instead.

Parameters:
nm - the case-insensitive property name
font - a default Font to return if property nm is not defined
Returns:
the Font value of the property.
See Also:
decode(String)

hashCode

public int hashCode()
Suppressed: Returns a hashcode for this Font.

Overrides:
hashCode in class Object
Returns:
a hashcode value for this Font.
Since:
JDK1.0
See Also:
java.lang.Object#equals(java.lang.Object), java.util.Hashtable

equals

public boolean equals(Object obj)
Suppressed: Compares this Font object to the specified Object.

Overrides:
equals in class Object
Parameters:
obj - the Object to compare
Returns:
true if the objects are the same or if the argument is a Font object describing the same font as this object; false otherwise.
Since:
JDK1.0
See Also:
Object.hashCode(), java.util.Hashtable

toString

public String toString()
Suppressed: Converts this Font object to a String representation.

Overrides:
toString in class Object
Returns:
a String representation of this Font object.
Since:
JDK1.0

writeObject

private void writeObject(ObjectOutputStream s)
                  throws ClassNotFoundException,
                         IOException
Writes default serializable fields to a stream.

Parameters:
s - the ObjectOutputStream to write
ClassNotFoundException
IOException
See Also:
AWTEventMulticaster.save(ObjectOutputStream, String, EventListener), readObject(java.io.ObjectInputStream)

readObject

private void readObject(ObjectInputStream s)
                 throws ClassNotFoundException,
                        IOException
Reads the ObjectInputStream. Unrecognized keys or values will be ignored.

Parameters:
s - the ObjectInputStream to read
ClassNotFoundException
IOException
See Also:
writeObject(java.io.ObjectOutputStream)

getNumGlyphs

public int getNumGlyphs()
Enabled: Returns the number of glyphs in this Font. Glyph codes for this Font range from 0 to getNumGlyphs() - 1.

Returns:
the number of glyphs in this Font.
Since:
1.2

getMissingGlyphCode

public int getMissingGlyphCode()
Enabled: Returns the glyphCode which is used when this Font does not have a glyph for a specified unicode.

Returns:
the glyphCode of this Font.
Since:
1.2

getMatrix

private double[] getMatrix()

getBaselineFor

public byte getBaselineFor(char c)
Enabled: Returns the baseline appropriate for displaying this character.

Large fonts can support different writing systems, and each system can use a different baseline. The character argument determines the writing system to use. Clients should not assume all characters use the same baseline.

Parameters:
c - a character used to identify the writing system
Returns:
the baseline appropriate for the specified character.
Since:
1.2
See Also:
LineMetrics.getBaselineOffsets(), ROMAN_BASELINE, CENTER_BASELINE, HANGING_BASELINE

getAttributes

public Map getAttributes()
Enabled: Returns a map of font attributes available in this Font. Attributes include things like ligatures and glyph substitution.

Returns:
the attributes map of this Font.

getAvailableAttributes

public java.text.AttributedCharacterIterator.Attribute[] getAvailableAttributes()
Enabled: Returns the keys of all the attributes supported by this Font. These attributes can be used to derive other fonts.

Returns:
an array containing the keys of all the attributes supported by this Font.
Since:
1.2

deriveFont

public Font deriveFont(int style,
                       float size)
Enabled: Creates a new Font object by replicating this Font object and applying a new style and size.

Parameters:
style - the style for the new Font
size - the size for the new Font
Returns:
a new Font object.
Since:
1.2

deriveFont

public Font deriveFont(int style,
                       java.awt.geom.AffineTransform trans)
Enabled: Creates a new Font object by replicating this Font object and applying a new style and transform.

Parameters:
style - the style for the new Font
trans - the AffineTransform associated with the new Font
Returns:
a new Font object.
Throws:
IllegalArgumentException - if trans is null
Since:
1.2

deriveFont

public Font deriveFont(float size)
Enabled: Creates a new Font object by replicating the current Font object and applying a new size to it.

Parameters:
size - the size for the new Font.
Returns:
a new Font object.
Since:
1.2

deriveFont

public Font deriveFont(java.awt.geom.AffineTransform trans)
Enabled: Creates a new Font object by replicating the current Font object and applying a new transform to it.

Parameters:
trans - the AffineTransform associated with the new Font
Returns:
a new Font object.
Throws:
IllegalArgumentException - if trans is null
Since:
1.2

deriveFont

public Font deriveFont(int style)
Enabled: Creates a new Font object by replicating the current Font object and applying a new style to it.

Parameters:
style - the style for the new Font
Returns:
a new Font object.
Since:
1.2

deriveFont

public Font deriveFont(Map attributes)
Enabled: Creates a new Font object by replicating the current Font object and applying a new set of font attributes to it.

Parameters:
attributes - a map of attributes enabled for the new Font
Returns:
a new Font object.
Since:
1.2

canDisplay

public boolean canDisplay(char c)
Enabled: Checks if this Font has a glyph for the specified character.

Parameters:
c - a unicode character code
Returns:
true if this Font can display the character; false otherwise.
Since:
1.2

canDisplayUpTo

public int canDisplayUpTo(String str)
Enabled: Indicates whether or not this Font can display a specified String. For strings with Unicode encoding, it is important to know if a particular font can display the string. This method returns an offset into the String str which is the first character this Font cannot display without using the missing glyph code. If the Font can display all characters, -1 is returned.

Parameters:
str - a String object
Returns:
an offset into str that points to the first character in str that this Font cannot display; or -1 if this Font can display all characters in str.
Since:
1.2

canDisplayUpTo

public int canDisplayUpTo(char[] text,
                          int start,
                          int limit)
Enabled: Indicates whether or not this Font can display the characters in the specified text starting at start and ending at limit. This method is a convenience overload.

Parameters:
text - the specified array of characters
start - the specified starting offset into the specified array of characters
limit - the specified ending offset into the specified array of characters
Returns:
an offset into text that points to the first character in text that this Font cannot display; or -1 if this Font can display all characters in text.
Since:
1.2

canDisplayUpTo

public int canDisplayUpTo(java.text.CharacterIterator iter,
                          int start,
                          int limit)
Enabled: Indicates whether or not this Font can display the specified String. For strings with Unicode encoding, it is important to know if a particular font can display the string. This method returns an offset into the String str which is the first character this Font cannot display without using the missing glyph code . If this Font can display all characters, -1 is returned.

Parameters:
iter - a CharacterIterator object
start - the specified starting offset into the specified array of characters
limit - the specified ending offset into the specified array of characters
Returns:
an offset into the String object that can be displayed by this Font.
Since:
1.2

getItalicAngle

public float getItalicAngle()
Enabled: Returns the italic angle of this Font. The italic angle is the inverse slope of the caret which best matches the posture of this Font.

Returns:
the angle of the ITALIC style of this Font.
See Also:
TextAttribute.POSTURE

hasUniformLineMetrics

public boolean hasUniformLineMetrics()
Enabled: Checks whether or not this Font has uniform line metrics. A logical Font might be a composite font, which means that it is composed of different physical fonts to cover different code ranges. Each of these fonts might have different LineMetrics. If the logical Font is a single font then the metrics would be uniform.

Returns:
true if this Font has uniform line metrics; false otherwise.

defaultLineMetrics

private java.awt.Font.FontLineMetrics defaultLineMetrics(java.awt.font.FontRenderContext frc)

getLineMetrics

public java.awt.font.LineMetrics getLineMetrics(String str,
                                                java.awt.font.FontRenderContext frc)
Enabled: Returns a LineMetrics object created with the specified String and FontRenderContext.

Parameters:
str - the specified String
frc - the specified FontRenderContext
Returns:
a LineMetrics object created with the specified String and FontRenderContext.

getLineMetrics

public java.awt.font.LineMetrics getLineMetrics(String str,
                                                int beginIndex,
                                                int limit,
                                                java.awt.font.FontRenderContext frc)
Enabled: Returns a LineMetrics object created with the specified arguments.

Parameters:
str - the specified String
beginIndex - the initial offset of str
limit - the end offset of str
frc - the specified FontRenderContext
Returns:
a LineMetrics object created with the specified arguments.

getLineMetrics

public java.awt.font.LineMetrics getLineMetrics(char[] chars,
                                                int beginIndex,
                                                int limit,
                                                java.awt.font.FontRenderContext frc)
Enabled: Returns a LineMetrics object created with the specified arguments.

Parameters:
chars - an array of characters
beginIndex - the initial offset of chars
limit - the end offset of chars
frc - the specified FontRenderContext
Returns:
a LineMetrics object created with the specified arguments.

getLineMetrics

public java.awt.font.LineMetrics getLineMetrics(java.text.CharacterIterator ci,
                                                int beginIndex,
                                                int limit,
                                                java.awt.font.FontRenderContext frc)
Enabled: Returns a LineMetrics object created with the specified arguments.

Parameters:
ci - the specified CharacterIterator
beginIndex - the initial offset in ci
limit - the end offset of ci
frc - the specified FontRenderContext
Returns:
a LineMetrics object created with the specified arguments.

getStringBounds

public java.awt.geom.Rectangle2D getStringBounds(String str,
                                                 java.awt.font.FontRenderContext frc)
Enabled: Returns the logical bounds of the specified String in the specified FontRenderContext. The logical bounds contains the origin, ascent, advance, and height, which includes the leading. The logical bounds does not always enclose all the text. For example, in some languages and in some fonts, accent marks can be positioned above the ascent or below the descent. To obtain a visual bounding box, which encloses all the text, use the getBounds method of TextLayout.

Parameters:
str - the specified String
frc - the specified FontRenderContext
Returns:
a Rectangle2D that is the bounding box of the specified String in the specified FontRenderContext.
Since:
1.2
See Also:
FontRenderContext, createGlyphVector(java.awt.font.FontRenderContext, java.lang.String)

getStringBounds

public java.awt.geom.Rectangle2D getStringBounds(String str,
                                                 int beginIndex,
                                                 int limit,
                                                 java.awt.font.FontRenderContext frc)
Enabled: Returns the logical bounds of the specified String in the specified FontRenderContext. The logical bounds contains the origin, ascent, advance, and height, which includes the leading. The logical bounds does not always enclose all the text. For example, in some languages and in some fonts, accent marks can be positioned above the ascent or below the descent. To obtain a visual bounding box, which encloses all the text, use the getBounds method of TextLayout.

Parameters:
str - the specified String
beginIndex - the initial offset of str
limit - the end offset of str
frc - the specified FontRenderContext
Returns:
a Rectangle2D that is the bounding box of the specified String in the specified FontRenderContext.
Throws:
IndexOutOfBoundsException - if beginIndex is less than zero, or limit is greater than the length of str, or beginIndex is greater than limit.
Since:
1.2
See Also:
FontRenderContext, createGlyphVector(java.awt.font.FontRenderContext, java.lang.String)

getStringBounds

public java.awt.geom.Rectangle2D getStringBounds(char[] chars,
                                                 int beginIndex,
                                                 int limit,
                                                 java.awt.font.FontRenderContext frc)
Enabled: Returns the logical bounds of the specified array of characters in the specified FontRenderContext. The logical bounds contains the origin, ascent, advance, and height, which includes the leading. The logical bounds does not always enclose all the text. For example, in some languages and in some fonts, accent marks can be positioned above the ascent or below the descent. To obtain a visual bounding box, which encloses all the text, use the getBounds method of TextLayout.

Parameters:
chars - an array of characters
beginIndex - the initial offset in the array of characters
limit - the end offset in the array of characters
frc - the specified FontRenderContext
Returns:
a Rectangle2D that is the bounding box of the specified array of characters in the specified FontRenderContext.
Throws:
IndexOutOfBoundsException - if beginIndex is less than zero, or limit is greater than the length of chars, or beginIndex is greater than limit.
Since:
1.2
See Also:
FontRenderContext, createGlyphVector(java.awt.font.FontRenderContext, java.lang.String)

getStringBounds

public java.awt.geom.Rectangle2D getStringBounds(java.text.CharacterIterator ci,
                                                 int beginIndex,
                                                 int limit,
                                                 java.awt.font.FontRenderContext frc)
Enabled: Returns the logical bounds of the characters indexed in the specified CharacterIterator in the specified FontRenderContext. The logical bounds contains the origin, ascent, advance, and height, which includes the leading. The logical bounds does not always enclose all the text. For example, in some languages and in some fonts, accent marks can be positioned above the ascent or below the descent. To obtain a visual bounding box, which encloses all the text, use the getBounds method of TextLayout.

Parameters:
ci - the specified CharacterIterator
beginIndex - the initial offset in ci
limit - the end offset in ci
frc - the specified FontRenderContext
Returns:
a Rectangle2D that is the bounding box of the characters indexed in the specified CharacterIterator in the specified FontRenderContext.
Throws:
IndexOutOfBoundsException - if beginIndex is less than the start index of ci, or limit is greater than the end index of ci, or beginIndex is greater than limit
Since:
1.2
See Also:
FontRenderContext, createGlyphVector(java.awt.font.FontRenderContext, java.lang.String)

getMaxCharBounds

public java.awt.geom.Rectangle2D getMaxCharBounds(java.awt.font.FontRenderContext frc)
Enabled: Returns the bounds for the character with the maximum bounds as defined in the specified FontRenderContext.

Parameters:
frc - the specified FontRenderContext
Returns:
a Rectangle2D that is the bounding box for the character with the maximum bounds.

createGlyphVector

public java.awt.font.GlyphVector createGlyphVector(java.awt.font.FontRenderContext frc,
                                                   String str)
Enabled: Creates a GlyphVector by mapping characters to glyphs one-to-one based on the Unicode cmap in this Font. This method does no other processing besides the mapping of glyphs to characters. This means that this method is not useful for some scripts, such as Arabic, Hebrew, Thai, and Indic, that require reordering, shaping, or ligature substitution.

Parameters:
frc - the specified FontRenderContext
str - the specified String
Returns:
a new GlyphVector created with the specified String and the specified FontRenderContext.

createGlyphVector

public java.awt.font.GlyphVector createGlyphVector(java.awt.font.FontRenderContext frc,
                                                   char[] chars)
Enabled: Creates a GlyphVector by mapping characters to glyphs one-to-one based on the Unicode cmap in this Font. This method does no other processing besides the mapping of glyphs to characters. This means that this method is not useful for some scripts, such as Arabic, Hebrew, Thai, and Indic, that require reordering, shaping, or ligature substitution.

Parameters:
frc - the specified FontRenderContext
chars - the specified array of characters
Returns:
a new GlyphVector created with the specified array of characters and the specified FontRenderContext.

createGlyphVector

public java.awt.font.GlyphVector createGlyphVector(java.awt.font.FontRenderContext frc,
                                                   java.text.CharacterIterator ci)
Enabled: Creates a GlyphVector by mapping the specified characters to glyphs one-to-one based on the Unicode cmap in this Font. This method does no other processing besides the mapping of glyphs to characters. This means that this method is not useful for some scripts, such as Arabic, Hebrew, Thai, and Indic, that require reordering, shaping, or ligature substitution.

Parameters:
frc - the specified FontRenderContext
ci - the specified CharacterIterator
Returns:
a new GlyphVector created with the specified CharacterIterator and the specified FontRenderContext.

createGlyphVector

public java.awt.font.GlyphVector createGlyphVector(java.awt.font.FontRenderContext frc,
                                                   int[] glyphCodes)
Enabled: Creates a GlyphVector by mapping characters to glyphs one-to-one based on the Unicode cmap in this Font. This method does no other processing besides the mapping of glyphs to characters. This means that this method is not useful for some scripts, such as Arabic, Hebrew, Thai, and Indic, that require reordering, shaping, or ligature substitution.

Parameters:
frc - the specified FontRenderContext
glyphCodes - the specified integer array
Returns:
a new GlyphVector created with the specified integer array and the specified FontRenderContext.

layoutGlyphVector

public java.awt.font.GlyphVector layoutGlyphVector(java.awt.font.FontRenderContext frc,
                                                   char[] text,
                                                   int start,
                                                   int limit,
                                                   int flags)
Suppressed: Returns a new GlyphVector object, performing full layout of the text if possible. Full layout is required for complex text, such as Arabic or Hindi. Support for different scripts depends on the font and implementation.

Bidi, and should only be performed on text that has a uniform direction. The direction is indicated in the flags parameter,by using LAYOUT_RIGHT_TO_LEFT to indicate a right-to-left (Arabic and Hebrew) run direction, or LAYOUT_LEFT_TO_RIGHT to indicate a left-to-right (English) run direction.

In addition, some operations, such as Arabic shaping, require context, so that the characters at the start and limit can have the proper shapes. Sometimes the data in the buffer outside the provided range does not have valid data. The values LAYOUT_NO_START_CONTEXT and LAYOUT_NO_LIMIT_CONTEXT can be added to the flags parameter to indicate that the text before start, or after limit, respectively, should not be examined for context.

All other values for the flags parameter are reserved.

Parameters:
frc - the specified FontRenderContext
text - the text to layout
start - the start of the text to use for the GlyphVector
limit - the limit of the text to use for the GlyphVector
flags - control flags as described above
Returns:
a new GlyphVector representing the text between start and limit, with glyphs chosen and positioned so as to best represent the text
Throws:
ArrayIndexOutOfBoundsException - if start or limit is out of bounds
See Also:
java.text.Bidi, LAYOUT_LEFT_TO_RIGHT, LAYOUT_RIGHT_TO_LEFT, LAYOUT_NO_START_CONTEXT, LAYOUT_NO_LIMIT_CONTEXT

applyTransform

private static void applyTransform(java.awt.geom.AffineTransform trans,
                                   Map attributes)

applyStyle

private static void applyStyle(int style,
                               Map attributes)

applySize

private static void applySize(float size,
                              Map attributes)

initIDs

private static void initIDs()

pDispose

private void pDispose()

finalize

protected void finalize()
                 throws Throwable
Disposes the native Font object.

Overrides:
finalize in class Object
Throws:
Throwable - the Exception raised by this method


comments?