This documentation differs from the official API. Jadeite adds extra features to the API including: variable font sizes, constructions examples, placeholders for classes and methods, and auto-generated “See Also” links. Additionally it is missing some items found in standard Javadoc documentation, including: generics type information, “Deprecated” tags and comments, “See Also” links, along with other minor differences. Please send any questions or feedback to bam@cs.cmu.edu.


java.awt.font
class FontRenderContext

java.lang.Object extended by java.awt.font.FontRenderContext

Most common way to construct:

Graphics2D g2 = …;

FontRenderContext frc = g2.getFontRenderContext();

Based on 150 examples


public class FontRenderContext
extends Object

The FontRenderContext class is a container for the information needed to correctly measure text. The measurement of text can vary because of rules that map outlines to pixels, and rendering hints provided by an application.

One such piece of information is a transform that scales typographical points to pixels. (A point is defined to be exactly 1/72 of an inch, which is slightly different than the traditional mechanical measurement of a point.) A character that is rendered at 12pt on a 600dpi device might have a different size than the same character rendered at 12pt on a 72dpi device because of such factors as rounding to pixel boundaries and hints that the font designer may have specified.

Anti-aliasing and Fractional-metrics specified by an application can also affect the size of a character because of rounding to pixel boundaries.

Typically, instances of FontRenderContext are obtained from a {@link java.awt.Graphics2D Graphics2D} object. A FontRenderContext which is directly constructed will most likely not represent any actual graphics device, and may lead to unexpected or incorrect results.


Constructor Summary
protected

          Constructs a new FontRenderContext object.
 
FontRenderContext(AffineTransform tx, boolean isAntiAliased, boolean usesFractionalMetrics)

          Constructs a FontRenderContext object from an optional java.awt.geom.AffineTransform and two boolean values that determine if the newly constructed object has anti-aliasing or fractional metrics.
 

          Constructs a FontRenderContext object from an optional java.awt.geom.AffineTransform and two Object values that determine if the newly constructed object has anti-aliasing or fractional metrics.
 
Method Summary
 boolean

          Return true if rhs has the same transform, antialiasing, and fractional metrics values as this.
 boolean

          Return true if obj is an instance of FontRenderContext and has the same transform, antialiasing, and fractional metrics values as this.
 Object

          Return the text anti-aliasing rendering mode hint used in this FontRenderContext.
 Object

          Return the text fractional metrics rendering mode hint used in this FontRenderContext.
 AffineTransform

          Gets the transform that is used to scale typographical points to pixels in this FontRenderContext.
 int

          Returns the integer type of the affine transform for this FontRenderContext as specified by java.awt.geom.AffineTransform.getType
 int

          Return a hashcode for this FontRenderContext.
 boolean

          Returns a boolean which indicates whether or not some form of antialiasing is specified by this FontRenderContext.
 boolean

          Indicates whether or not this FontRenderContext object measures text in a transformed render context.
 boolean

          Returns a boolean which whether text fractional metrics mode is used in this FontRenderContext.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FontRenderContext

protected FontRenderContext()
Constructs a new FontRenderContext object.


FontRenderContext

public FontRenderContext(AffineTransform tx,
                         boolean isAntiAliased,
                         boolean usesFractionalMetrics)
Constructs a FontRenderContext object from an optional {@link AffineTransform} and two boolean values that determine if the newly constructed object has anti-aliasing or fractional metrics. In each case the boolean values true and false correspond to the rendering hint values ON and OFF respectively.

To specify other hint values, use the constructor which specifies the rendering hint values as parameters : {@link #FontRenderContext(AffineTransform, Object, Object)}.

Parameters:
tx - the transform which is used to scale typographical points to pixels in this FontRenderContext. If null, an identity transform is used.
isAntiAliased - determines if the newly constructed object has anti-aliasing.
usesFractionalMetrics - determines if the newly constructed object has fractional metrics.

FontRenderContext

public FontRenderContext(AffineTransform tx,
                         Object aaHint,
                         Object fmHint)
Constructs a FontRenderContext object from an optional {@link AffineTransform} and two Object values that determine if the newly constructed object has anti-aliasing or fractional metrics.

Parameters:
tx - the transform which is used to scale typographical points to pixels in this FontRenderContext. If null, an identity tranform is used.
aaHint - - one of the text antialiasing rendering hint values defined in {@link java.awt.RenderingHints java.awt.RenderingHints}. Any other value will throw IllegalArgumentException. {@link java.awt.RenderingHints#VALUE_TEXT_ANTIALIAS_DEFAULT VALUE_TEXT_ANTIALIAS_DEFAULT} may be specified, in which case the mode used is implementation dependent.
fmHint - - one of the text fractional rendering hint values defined in {@link java.awt.RenderingHints java.awt.RenderingHints}. {@link java.awt.RenderingHints#VALUE_FRACTIONALMETRICS_DEFAULT VALUE_FRACTIONALMETRICS_DEFAULT} may be specified, in which case the mode used is implementation dependent. Any other value will throw IllegalArgumentException
Method Detail

equals

public boolean equals(FontRenderContext rhs)
Return true if rhs has the same transform, antialiasing, and fractional metrics values as this.

Parameters:
rhs - the FontRenderContext to test for equality
Returns:
true if rhs is equal to this FontRenderContext; false otherwise.

equals

public boolean equals(Object obj)
Return true if obj is an instance of FontRenderContext and has the same transform, antialiasing, and fractional metrics values as this.

Overrides:
equals in class Object
Parameters:
obj - the object to test for equality
Returns:
true if the specified object is equal to this FontRenderContext; false otherwise.

getAntiAliasingHint

public Object getAntiAliasingHint()
Return the text anti-aliasing rendering mode hint used in this FontRenderContext. This will be one of the text antialiasing rendering hint values defined in {@link java.awt.RenderingHints java.awt.RenderingHints}.

Returns:
text anti-aliasing rendering mode hint used in this FontRenderContext.

getFractionalMetricsHint

public Object getFractionalMetricsHint()
Return the text fractional metrics rendering mode hint used in this FontRenderContext. This will be one of the text fractional metrics rendering hint values defined in {@link java.awt.RenderingHints java.awt.RenderingHints}.

Returns:
the text fractional metrics rendering mode hint used in this FontRenderContext.

getTransform

public AffineTransform getTransform()
Gets the transform that is used to scale typographical points to pixels in this FontRenderContext.

Returns:
the AffineTransform of this FontRenderContext.

getTransformType

public int getTransformType()
Returns the integer type of the affine transform for this FontRenderContext as specified by {@link java.awt.geom.AffineTransform#getType()}

Returns:
the type of the transform.

hashCode

public int hashCode()
Return a hashcode for this FontRenderContext.

Overrides:
hashCode in class Object

isAntiAliased

public boolean isAntiAliased()
Returns a boolean which indicates whether or not some form of antialiasing is specified by this FontRenderContext. Call {@link #getAntiAliasingHint() getAntiAliasingHint()} for the specific rendering hint value.

Returns:
true, if text is anti-aliased in this FontRenderContext; false otherwise.

isTransformed

public boolean isTransformed()
Indicates whether or not this FontRenderContext object measures text in a transformed render context.

Returns:
true if this FontRenderContext object has a non-identity AffineTransform attribute. false otherwise.

usesFractionalMetrics

public boolean usesFractionalMetrics()
Returns a boolean which whether text fractional metrics mode is used in this FontRenderContext. Call {@link #getFractionalMetricsHint() getFractionalMetricsHint()} to obtain the corresponding rendering hint value.

Returns:
true, if layout should be performed with fractional metrics; false otherwise. in this FontRenderContext.


This documentation differs from the official API. Jadeite adds extra features to the API including: variable font sizes, constructions examples, placeholders for classes and methods, and auto-generated “See Also” links. Additionally it is missing some items found in standard Javadoc documentation, including: generics type information, “Deprecated” tags and comments, “See Also” links, along with other minor differences. Please send any questions or feedback to bam@cs.cmu.edu.
This page displays the Jadeite version of the documention, which is derived from the offical documentation that contains this copyright notice:
Copyright 2008 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.
The official Sun™ documentation can be found here at http://java.sun.com/javase/6/docs/api/.