The Font class represents fonts, which are used to render text in a visible way. A font provides the information needed to map sequences of characters to sequences of glyphs and to render sequences of glyphs on Graphics and Component objects.

Characters and Glyphs

A character is a symbol that represents an item such as a letter, a digit, or punctuation in an abstract way. For example, 'g', LATIN SMALL LETTER G, is a character.

A glyph is a shape used to render a character or a sequence of characters. In simple writing systems, such as Latin, typically one glyph represents one character. In general, however, characters and glyphs do not have one-to-one correspondence. For example, the character 'á' LATIN SMALL LETTER A WITH ACUTE, can be represented by two glyphs: one for 'a' and one for '´'. On the other hand, the two-character string "fi" can be represented by a single glyph, an "fi" ligature. In complex writing systems, such as Arabic or the South and South-East Asian writing systems, the relationship between characters and glyphs can be more complicated and involve context-dependent selection of glyphs as well as glyph reordering. A font encapsulates the collection of glyphs needed to render a selected set of characters as well as the tables needed to map sequences of characters to corresponding sequences of glyphs.

Physical and Logical Fonts

The Java 2 platform distinguishes between two kinds of fonts: physical fonts and logical fonts.

Physical fonts are the actual font libraries containing glyph data and tables to map from character sequences to glyph sequences, using a font technology such as TrueType or PostScript Type 1. All implementations of the Java 2 platform must support TrueType fonts; support for other font technologies is implementation dependent. Physical fonts may use names such as Helvetica, Palatino, HonMincho, or any number of other font names. Typically, each physical font supports only a limited set of writing systems, for example, only Latin characters or only Japanese and Basic Latin. The set of available physical fonts varies between configurations. Applications that require specific fonts can bundle them and instantiate them using the createFont method.

Logical fonts are the five font families defined by the Java platform which must be supported by any Java runtime environment: Serif, SansSerif, Monospaced, Dialog, and DialogInput. These logical fonts are not actual font libraries. Instead, the logical font names are mapped to physical fonts by the Java runtime environment. The mapping is implementation and usually locale dependent, so the look and the metrics provided by them vary. Typically, each logical font name maps to several physical fonts in order to cover a large range of characters.

Peered AWT components, such as Label and TextField , can only use logical fonts.

For a discussion of the relative advantages and disadvantages of using physical or logical fonts, see the Internationalization FAQ document.

Font Faces and Names

A Font can have many faces, such as heavy, medium, oblique, gothic and regular. All of these faces have similar typographic design.

There are three different names that you can get from a Font object. The logical font name is simply the name that was used to construct the font. The font face name, or just font name for short, is the name of a particular font face, like Helvetica Bold. The family name is the name of the font family that determines the typographic design across several faces, like Helvetica.

The Font class represents an instance of a font face from a collection of font faces that are present in the system resources of the host system. As examples, Arial Bold and Courier Bold Italic are font faces. There can be several Font objects associated with a font face, each differing in size, style, transform and font features. The getAllFonts method of the GraphicsEnvironment class returns an array of all font faces available in the system. These font faces are returned as Font objects with a size of 1, identity transform and default font features. These base fonts can then be used to derive new Font objects with varying sizes, styles, transforms and font features via the deriveFont methods in this class.

@version
1.200, 07/20/04
Creates a new Font from the specified name, style and point size.

The font name can be a font face name or a font family name. It is used together with the style to find an appropriate font face. When a font family name is specified, the style argument is used to select the most appropriate face from the family. When a font face name is specified, the face's style and the style argument are merged to locate the best matching font from the same family. For example if face name "Arial Bold" is specified with style Font.ITALIC, the font system looks for a face in the "Arial" family that is bold and italic, and may associate the font instance with the physical font face "Arial Bold Italic". The style argument is merged with the specified face's style, not added or subtracted. This means, specifying a bold face and a bold style does not double-embolden the font, and specifying a bold face and a plain style does not lighten the font.

If no face for the requested style can be found, the font system may apply algorithmic styling to achieve the desired style. For example, if ITALIC is requested, but no italic face is available, glyphs from the plain face may be algorithmically obliqued (slanted).

Font name lookup is case insensitive, using the case folding rules of the US locale.

Parameters
namethe font name. This can be a font face name or a font family name, and may represent either a logical font or a physical font found in this GraphicsEnvironment. The family names for logical fonts are: Dialog, DialogInput, Monospaced, Serif, or SansSerif. If name is null, the logical font name of the new Font as returned by getName()is set to the name "Default".
stylethe 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.
sizethe point size of the Font
@since
JDK1.0
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
attributesthe attributes to assign to the new Font, or null
The bold style constant. This can be combined with the other style constants (except PLAIN) for mixed styles.
The baseline used in ideographic scripts like Chinese, Japanese, and Korean when laying out text.
The baseline used in Devanigiri and similar scripts when laying out text.
The italicized style constant. This can be combined with the other style constants (except PLAIN) for mixed styles.
A flag to layoutGlyphVector indicating that text is left-to-right as determined by Bidi analysis.
A flag to layoutGlyphVector indicating that text in the char array after the indicated limit should not be examined.
A flag to layoutGlyphVector indicating that text in the char array before the indicated start should not be examined.
A flag to layoutGlyphVector indicating that text is right-to-left as determined by Bidi analysis.
The plain style constant.
The baseline used in most Roman scripts when laying out text.
Identify a font resource of type TRUETYPE. Used to specify a TrueType font resource to the #createFont method.
@since
1.3
Identify a font resource of type TYPE1. Used to specify a Type1 font resource to the #createFont method.
@since
1.5
Checks if this Font has a glyph for the specified character.

Note: This method cannot handle supplementary characters. To support all Unicode characters, including supplementary characters, use the method or canDisplayUpTo methods.

Parameters
cthe character for which a glyph is needed
Return
true if this Font has a glyph for this character; false otherwise.
@since
1.2
Checks if this Font has a glyph for the specified character.
Parameters
codePointthe character (Unicode code point) for which a glyph is needed.
Return
true if this Font has a glyph for the character; false otherwise.
Throws
IllegalArgumentExceptionif the code point is not a valid Unicode code point.
@since
1.5
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
textthe specified array of char values
startthe specified starting offset (in chars) into the specified array of char values
limitthe specified ending offset (in chars) into the specified array of char values
Return
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
Indicates whether or not this Font can display the text specified by the iter starting at start and ending at limit.
Parameters
itera {@link CharacterIterator} object
startthe specified starting offset into the specified CharacterIterator.
limitthe specified ending offset into the specified CharacterIterator.
Return
an offset into iter that points to the first character in iter that this Font cannot display; or -1 if this Font can display all characters in iter.
@since
1.2
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
stra String object
Return
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
Returns a new Font using the specified font type and the specified font file. 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.
Parameters
fontFormatthe type of the Font, which is {@link #TRUETYPE_FONT TRUETYPE_FONT} if a TrueType resource is specified or {@link #TYPE1_FONT TYPE1_FONT} if a Type 1 resource is specified. So long as the returned font, or its derived fonts are referenced the implementation may continue to access fontFile to retrieve font data. Thus the results are undefined if the file is changed, or becomes inaccessible.
fontFilea File object representing the input data for the font.
Return
a new Font created with the specified font type.
Throws
IllegalArgumentExceptionif fontFormat is not TRUETYPE_FONTorTYPE1_FONT.
NullPointerExceptionif fontFile is null.
IOExceptionif the fontFile cannot be read.
FontFormatExceptionif fontFile does not contain the required font tables for the specified format.
SecurityExceptionif the executing code does not have permission to read from the file.
@since
1.5
Returns a new Font using 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
fontFormatthe type of the Font, which is {@link #TRUETYPE_FONT TRUETYPE_FONT} if a TrueType resource is specified. or {@link #TYPE1_FONT TYPE1_FONT} if a Type 1 resource is specified.
fontStreaman InputStream object representing the input data for the font.
Return
a new Font created with the specified font type.
Throws
IllegalArgumentExceptionif fontFormat is not TRUETYPE_FONTorTYPE1_FONT.
FontFormatExceptionif the fontStream data does not contain the required font tables for the specified format.
IOExceptionif the fontStream cannot be completely read.
@since
1.3
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
frcthe specified FontRenderContext
charsthe specified array of characters
Return
a new GlyphVector created with the specified array of characters and the specified FontRenderContext.
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
frcthe specified FontRenderContext
cithe specified CharacterIterator
Return
a new GlyphVector created with the specified CharacterIterator and the specified FontRenderContext.
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
frcthe specified FontRenderContext
glyphCodesthe specified integer array
Return
a new GlyphVector created with the specified integer array and the specified FontRenderContext.
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
frcthe specified FontRenderContext
strthe specified String
Return
a new GlyphVector created with the specified String and the specified FontRenderContext.
Returns the Font that the str argument describes. To ensure that this method returns the desired Font, format the str parameter in one of these ways

  • fontname-style-pointsize
  • fontname-pointsize
  • fontname-style
  • fontname
  • fontname style pointsize
  • fontname pointsize
  • fontname style
  • fontname
in which style is one of the four case-insensitive strings: "PLAIN", "BOLD", "BOLDITALIC", or "ITALIC", and pointsize is a positive decimal integer representation of the point size. For example, if you want a font that is Arial, bold, with a point size of 18, you would call this method with: "Arial-BOLD-18". This is equivalent to calling the Font constructor : new Font("Arial", Font.BOLD, 18); and the values are interpreted as specified by that constructor.

A valid trailing decimal field is always interpreted as the pointsize. Therefore a fontname containing a trailing decimal value should not be used in the fontname only form.

If a style name field is not one of the valid style strings, it is interpreted as part of the font name, and the default style is used.

Only one of ' ' or '-' may be used to separate fields in the input. The identified separator is the one closest to the end of the string which separates a valid pointsize, or a valid style name from the rest of the string. Null (empty) pointsize and style fields are treated as valid fields with the default value for that field.

Some font names may include the separator characters ' ' or '-'. If str is not formed with 3 components, e.g. such that style or pointsize fields are not present in str, and fontname also contains a character determined to be the separator character then these characters where they appear as intended to be part of fontname may instead be interpreted as separators so the font name may not be properly recognised.

The default size is 12 and the default style is PLAIN. If str does not specify a valid size, the returned Font has a size of 12. If str does not specify a valid style, the returned Font has a style of PLAIN. If you do not specify a valid font name in the str argument, this method will return a font with the family name "Dialog". To determine what font family names are available on your system, use the method. If str is null, a new Font is returned with the family name "Dialog", a size of 12 and a PLAIN style.

Parameters
strthe name of the font, or null
Return
the Font object that str describes, or a new default Font if str is null.
@since
JDK1.1
See Also
Creates a new Font object by replicating the current Font object and applying a new transform to it.
Parameters
transthe AffineTransform associated with the new Font
Return
a new Font object.
Throws
IllegalArgumentExceptionif trans is null
@since
1.2
Creates a new Font object by replicating the current Font object and applying a new size to it.
Parameters
sizethe size for the new Font.
Return
a new Font object.
@since
1.2
Creates a new Font object by replicating the current Font object and applying a new style to it.
Parameters
stylethe style for the new Font
Return
a new Font object.
@since
1.2
Creates a new Font object by replicating this Font object and applying a new style and transform.
Parameters
stylethe style for the new Font
transthe AffineTransform associated with the new Font
Return
a new Font object.
Throws
IllegalArgumentExceptionif trans is null
@since
1.2
Creates a new Font object by replicating this Font object and applying a new style and size.
Parameters
stylethe style for the new Font
sizethe size for the new Font
Return
a new Font object.
@since
1.2
Creates a new Font object by replicating the current Font object and applying a new set of font attributes to it.
Parameters
attributesa map of attributes enabled for the new Font
Return
a new Font object.
@since
1.2
Compares this Font object to the specified Object.
Parameters
objthe Object to compare
Return
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
Returns a map of font attributes available in this Font. Attributes include things like ligatures and glyph substitution.
Return
the attributes map of this Font.
Returns the keys of all the attributes supported by this Font. These attributes can be used to derive other fonts.
Return
an array containing the keys of all the attributes supported by this Font.
@since
1.2
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
ca character used to identify the writing system
Return
the baseline appropriate for the specified character.
@since
1.2
Returns the runtime class of an object. That Class object is the object that is locked by static synchronized methods of the represented class.
Return
The java.lang.Class object that represents the runtime class of the object. The result is of type {@code Class} where X is the erasure of the static type of the expression on which getClass is called.
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 method.

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

Return
a String that is the family name of this Font.
@since
JDK1.1
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 method.

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

Parameters
llocale for which to get the family name
Return
a String representing the family name of the font, localized for the specified locale.
@since
1.2
Returns a Font appropriate to this attribute set.
Parameters
attributesthe attributes to assign to the new Font
Return
a new Font created with the specified attributes
@since
1.2
Returns a Font object from the system properties list. nm 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 according to the specification of Font.decode(String) If the specified property is not found, null is returned instead.
Parameters
nmthe property name
Return
a Font object that the property name describes, or null if no such property exists.
Throws
NullPointerExceptionif nm is null.
@since
1.2
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 forms accepted by Font.decode(String) If the specified property is not found, the font argument is returned instead.

Parameters
nmthe case-insensitive property name
fonta default Font to return if property nm is not defined
Return
the Font value of the property.
Throws
NullPointerExceptionif nm is null.
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.
Return
a String representing the font face name of this Font.
@since
1.2
See Also
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
la locale for which to get the font face name
Return
a String representing the font face name, localized for the specified locale.
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.
Return
the angle of the ITALIC style of this Font.
Returns a LineMetrics object created with the specified arguments.
Parameters
charsan array of characters
beginIndexthe initial offset of chars
limitthe end offset of chars
frcthe specified FontRenderContext
Return
a LineMetrics object created with the specified arguments.
Returns a LineMetrics object created with the specified arguments.
Parameters
cithe specified CharacterIterator
beginIndexthe initial offset in ci
limitthe end offset of ci
frcthe specified FontRenderContext
Return
a LineMetrics object created with the specified arguments.
Returns a LineMetrics object created with the specified String and FontRenderContext .
Parameters
strthe specified String
frcthe specified FontRenderContext
Return
a LineMetrics object created with the specified String and {@link FontRenderContext}.
Returns a LineMetrics object created with the specified arguments.
Parameters
strthe specified String
beginIndexthe initial offset of str
limitthe end offset of str
frcthe specified FontRenderContext
Return
a LineMetrics object created with the specified arguments.
Returns the bounds for the character with the maximum bounds as defined in the specified FontRenderContext.
Parameters
frcthe specified FontRenderContext
Return
a Rectangle2D that is the bounding box for the character with the maximum bounds.
Returns the glyphCode which is used when this Font does not have a glyph for a specified unicode.
Return
the glyphCode of this Font.
@since
1.2
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.
Return
a String representing the logical name of this Font.
@since
JDK1.0
Returns the number of glyphs in this Font. Glyph codes for this Font range from 0 to getNumGlyphs() - 1.
Return
the number of glyphs in this Font.
@since
1.2
Gets the peer of this Font.
Return
the peer of the Font.
@since
JDK1.1
@deprecated
Font rendering is now platform independent.
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.
Return
a String representing the postscript name of this Font.
@since
1.2
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.

Return
the point size of this Font in 1/72 of an inch units.
@since
JDK1.0
Returns the point size of this Font in float value.
Return
the point size of this Font as a float value.
@since
1.2
See Also
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
charsan array of characters
beginIndexthe initial offset in the array of characters
limitthe end offset in the array of characters
frcthe specified FontRenderContext
Return
a Rectangle2D that is the bounding box of the specified array of characters in the specified FontRenderContext.
Throws
IndexOutOfBoundsExceptionif beginIndex is less than zero, or limit is greater than the length of chars, or beginIndex is greater than limit.
@since
1.2
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
cithe specified CharacterIterator
beginIndexthe initial offset in ci
limitthe end offset in ci
frcthe specified FontRenderContext
Return
a Rectangle2D that is the bounding box of the characters indexed in the specified CharacterIterator in the specified FontRenderContext.
Throws
IndexOutOfBoundsExceptionif 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
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
strthe specified String
frcthe specified FontRenderContext
Return
a {@link Rectangle2D} that is the bounding box of the specified String in the specified FontRenderContext.
@since
1.2
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
strthe specified String
beginIndexthe initial offset of str
limitthe end offset of str
frcthe specified FontRenderContext
Return
a Rectangle2D that is the bounding box of the specified String in the specified FontRenderContext.
Throws
IndexOutOfBoundsExceptionif beginIndex is less than zero, or limit is greater than the length of str, or beginIndex is greater than limit.
@since
1.2
Returns the style of this Font. The style can be PLAIN, BOLD, ITALIC, or BOLD+ITALIC.
Return
the style of this Font
@since
JDK1.0
Returns a copy of the transform associated with this Font.
Return
an {@link AffineTransform} object representing the transform attribute of this Font object.
Returns a hashcode for this Font.
Return
a hashcode value for this Font.
@since
JDK1.0
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.
Return
true if this Font has uniform line metrics; false otherwise.
Indicates whether or not this Font object's style is BOLD.
Return
true if this Font object's style is BOLD; false otherwise.
@since
JDK1.0
Indicates whether or not this Font object's style is ITALIC.
Return
true if this Font object's style is ITALIC; false otherwise.
@since
JDK1.0
Indicates whether or not this Font object's style is PLAIN.
Return
true if this Font has a PLAIN sytle; false otherwise.
@since
JDK1.0
Indicates whether or not this Font object has a transform that affects its size in addition to the Size attribute.
Return
true if this Font object has a non-identity AffineTransform attribute. false otherwise.
@since
1.4
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
frcthe specified FontRenderContext
textthe text to layout
startthe start of the text to use for the GlyphVector
limitthe limit of the text to use for the GlyphVector
flagscontrol flags as described above
Return
a new GlyphVector representing the text between start and limit, with glyphs chosen and positioned so as to best represent the text
Throws
ArrayIndexOutOfBoundsExceptionif start or limit is out of bounds
Wakes up a single thread that is waiting on this object's monitor. If any threads are waiting on this object, one of them is chosen to be awakened. The choice is arbitrary and occurs at the discretion of the implementation. A thread waits on an object's monitor by calling one of the wait methods.

The awakened thread will not be able to proceed until the current thread relinquishes the lock on this object. The awakened thread will compete in the usual manner with any other threads that might be actively competing to synchronize on this object; for example, the awakened thread enjoys no reliable privilege or disadvantage in being the next thread to lock this object.

This method should only be called by a thread that is the owner of this object's monitor. A thread becomes the owner of the object's monitor in one of three ways:

  • By executing a synchronized instance method of that object.
  • By executing the body of a synchronized statement that synchronizes on the object.
  • For objects of type Class, by executing a synchronized static method of that class.

Only one thread at a time can own an object's monitor.

Throws
IllegalMonitorStateExceptionif the current thread is not the owner of this object's monitor.
Wakes up all threads that are waiting on this object's monitor. A thread waits on an object's monitor by calling one of the wait methods.

The awakened threads will not be able to proceed until the current thread relinquishes the lock on this object. The awakened threads will compete in the usual manner with any other threads that might be actively competing to synchronize on this object; for example, the awakened threads enjoy no reliable privilege or disadvantage in being the next thread to lock this object.

This method should only be called by a thread that is the owner of this object's monitor. See the notify method for a description of the ways in which a thread can become the owner of a monitor.

Throws
IllegalMonitorStateExceptionif the current thread is not the owner of this object's monitor.
Converts this Font object to a String representation.
Return
a String representation of this Font object.
@since
JDK1.0
Causes current thread to wait until another thread invokes the method or the method for this object. In other words, this method behaves exactly as if it simply performs the call wait(0).

The current thread must own this object's monitor. The thread releases ownership of this monitor and waits until another thread notifies threads waiting on this object's monitor to wake up either through a call to the notify method or the notifyAll method. The thread then waits until it can re-obtain ownership of the monitor and resumes execution.

As in the one argument version, interrupts and spurious wakeups are possible, and this method should always be used in a loop:

     synchronized (obj) {
         while (<condition does not hold>)
             obj.wait();
         ... // Perform action appropriate to condition
     }
 
This method should only be called by a thread that is the owner of this object's monitor. See the notify method for a description of the ways in which a thread can become the owner of a monitor.
Throws
IllegalMonitorStateExceptionif the current thread is not the owner of the object's monitor.
InterruptedExceptionif another thread interrupted the current thread before or while the current thread was waiting for a notification. The interrupted status of the current thread is cleared when this exception is thrown.
Causes current thread to wait until either another thread invokes the method or the method for this object, or a specified amount of time has elapsed.

The current thread must own this object's monitor.

This method causes the current thread (call it T) to place itself in the wait set for this object and then to relinquish any and all synchronization claims on this object. Thread T becomes disabled for thread scheduling purposes and lies dormant until one of four things happens:

  • Some other thread invokes the notify method for this object and thread T happens to be arbitrarily chosen as the thread to be awakened.
  • Some other thread invokes the notifyAll method for this object.
  • Some other thread interrupts thread T.
  • The specified amount of real time has elapsed, more or less. If timeout is zero, however, then real time is not taken into consideration and the thread simply waits until notified.
The thread T is then removed from the wait set for this object and re-enabled for thread scheduling. It then competes in the usual manner with other threads for the right to synchronize on the object; once it has gained control of the object, all its synchronization claims on the object are restored to the status quo ante - that is, to the situation as of the time that the wait method was invoked. Thread T then returns from the invocation of the wait method. Thus, on return from the wait method, the synchronization state of the object and of thread T is exactly as it was when the wait method was invoked.

A thread can also wake up without being notified, interrupted, or timing out, a so-called spurious wakeup. While this will rarely occur in practice, applications must guard against it by testing for the condition that should have caused the thread to be awakened, and continuing to wait if the condition is not satisfied. In other words, waits should always occur in loops, like this one:

     synchronized (obj) {
         while (<condition does not hold>)
             obj.wait(timeout);
         ... // Perform action appropriate to condition
     }
 
(For more information on this topic, see Section 3.2.3 in Doug Lea's "Concurrent Programming in Java (Second Edition)" (Addison-Wesley, 2000), or Item 50 in Joshua Bloch's "Effective Java Programming Language Guide" (Addison-Wesley, 2001).

If the current thread is interrupted by another thread while it is waiting, then an InterruptedException is thrown. This exception is not thrown until the lock status of this object has been restored as described above.

Note that the wait method, as it places the current thread into the wait set for this object, unlocks only this object; any other objects on which the current thread may be synchronized remain locked while the thread waits.

This method should only be called by a thread that is the owner of this object's monitor. See the notify method for a description of the ways in which a thread can become the owner of a monitor.

Parameters
timeoutthe maximum time to wait in milliseconds.
Throws
IllegalArgumentExceptionif the value of timeout is negative.
IllegalMonitorStateExceptionif the current thread is not the owner of the object's monitor.
InterruptedExceptionif another thread interrupted the current thread before or while the current thread was waiting for a notification. The interrupted status of the current thread is cleared when this exception is thrown.
Causes current thread to wait until another thread invokes the method or the method for this object, or some other thread interrupts the current thread, or a certain amount of real time has elapsed.

This method is similar to the wait method of one argument, but it allows finer control over the amount of time to wait for a notification before giving up. The amount of real time, measured in nanoseconds, is given by:

 1000000*timeout+nanos

In all other respects, this method does the same thing as the method of one argument. In particular, wait(0, 0) means the same thing as wait(0).

The current thread must own this object's monitor. The thread releases ownership of this monitor and waits until either of the following two conditions has occurred:

  • Another thread notifies threads waiting on this object's monitor to wake up either through a call to the notify method or the notifyAll method.
  • The timeout period, specified by timeout milliseconds plus nanos nanoseconds arguments, has elapsed.

The thread then waits until it can re-obtain ownership of the monitor and resumes execution.

As in the one argument version, interrupts and spurious wakeups are possible, and this method should always be used in a loop:

     synchronized (obj) {
         while (<condition does not hold>)
             obj.wait(timeout, nanos);
         ... // Perform action appropriate to condition
     }
 
This method should only be called by a thread that is the owner of this object's monitor. See the notify method for a description of the ways in which a thread can become the owner of a monitor.
Parameters
timeoutthe maximum time to wait in milliseconds.
nanosadditional time, in nanoseconds range 0-999999.
Throws
IllegalArgumentExceptionif the value of timeout is negative or the value of nanos is not in the range 0-999999.
IllegalMonitorStateExceptionif the current thread is not the owner of this object's monitor.
InterruptedExceptionif another thread interrupted the current thread before or while the current thread was waiting for a notification. The interrupted status of the current thread is cleared when this exception is thrown.