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 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.
java.awt.RenderingHints#KEY_TEXT_ANTIALIASING , java.awt.RenderingHints#KEY_FRACTIONALMETRICS , java.awt.Graphics2D#getFontRenderContext() , java.awt.font.LineMetrics
| Modifier and Type | Field and Description |
|---|---|
| private final transient Object | |
| private final transient boolean | |
| private final transient Object | |
| private final transient AffineTransform |
| Access | Constructor and Description |
|---|---|
| protected | |
| public | FontRenderContext(AffineTransform
the transform which is used to scale typographical points
to pixels in this tx, boolean FontRenderContext. If null, an
identity transform is used.determines if the newly constructed object
has anti-aliasing. isAntiAliased, boolean determines if the newly constructed
object has fractional metrics. usesFractionalMetrics)Constructs a |
| public | FontRenderContext(AffineTransform
the transform which is used to scale typographical points
to pixels in this tx, Object FontRenderContext. If null, an
identity transform is used.one of the text antialiasing rendering hint values
defined in aaHint, Object java..
Any other value will throw IllegalArgumentException.
VALUE_TEXT_ANTIALIAS_DEFAULT
may be specified, in which case the mode used is implementation
dependent.one of the text fractional rendering hint values defined
in fmHint)java..
VALUE_FRACTIONALMETRICS_DEFAULT
may be specified, in which case the mode used is implementation
dependent.
Any other value will throw IllegalArgumentExceptionConstructs a |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | Returns: true if the specified object is equal to
this FontRenderContext; false
otherwise.the object to test for equality obj)Overrides java. Return true if obj is an instance of FontRenderContext and has the same transform, antialiasing, and fractional metrics values as this. |
| public boolean | Returns: true if rhs is equal to
this FontRenderContext; false
otherwise.the rhs)FontRenderContext to test for equalityReturn true if rhs has the same transform, antialiasing, and fractional metrics values as this. |
| public Object | Returns: text anti-aliasing rendering mode hint used in thisFontRenderContext.Return the text anti-aliasing rendering mode hint used in this
|
| public Object | Returns: the text fractional metrics rendering mode hint used in thisFontRenderContext.Return the text fractional metrics rendering mode hint used in this
|
| public AffineTransform | Returns: theAffineTransform of this
FontRenderContext.Gets the transform that is used to scale typographical points
to pixels in this |
| public int | Returns: the type of the transform.Returns the integer type of the affine transform for this
|
| public int | |
| public boolean | Returns: true, if text is anti-aliased in this
FontRenderContext; false otherwise.Returns a boolean which indicates whether or not some form of
antialiasing is specified by this |
| public boolean | Returns: true if this FontRenderContext
object has a non-identity AffineTransform attribute.
false otherwise.Indicates whether or not this |
| public boolean | Returns: true, if layout should be performed with
fractional metrics; false otherwise.
in this FontRenderContext.Returns a boolean which whether text fractional metrics mode
is used in this |
| aaHintValue | back to summary |
|---|---|
| private final transient Object aaHintValue | |
| defaulting | back to summary |
|---|---|
| private final transient boolean defaulting | |
| fmHintValue | back to summary |
|---|---|
| private final transient Object fmHintValue | |
| tx | back to summary |
|---|---|
| private final transient AffineTransform tx | |
| FontRenderContext | back to summary |
|---|---|
| protected FontRenderContext() Constructs a new | |
| FontRenderContext | back to summary |
|---|---|
| public FontRenderContext(AffineTransform tx, boolean isAntiAliased, boolean usesFractionalMetrics) Constructs a
To specify other hint values, use the constructor which
specifies the rendering hint values as parameters :
| |
| FontRenderContext | back to summary |
|---|---|
| public FontRenderContext(AffineTransform tx, Object aaHint, Object fmHint) Constructs a
| |
| equals | back to summary |
|---|---|
| public boolean equals(Object obj) Overrides java. Return true if obj is an instance of FontRenderContext and has the same transform, antialiasing, and fractional metrics values as this.
| |
| equals | back to summary |
|---|---|
| public boolean equals(FontRenderContext rhs) Return true if rhs has the same transform, antialiasing, and fractional metrics values as this.
| |
| getAntiAliasingHint | back to summary |
|---|---|
| public Object getAntiAliasingHint() Return the text anti-aliasing rendering mode hint used in this
| |
| getFractionalMetricsHint | back to summary |
|---|---|
| public Object getFractionalMetricsHint() Return the text fractional metrics rendering mode hint used in this
| |
| getTransform | back to summary |
|---|---|
| public AffineTransform getTransform() Gets the transform that is used to scale typographical points
to pixels in this
| |
| getTransformType | back to summary |
|---|---|
| public int getTransformType() Returns the integer type of the affine transform for this
| |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Return a hashcode for this FontRenderContext. | |
| isAntiAliased | back to summary |
|---|---|
| public boolean isAntiAliased() Returns a boolean which indicates whether or not some form of
antialiasing is specified by this
| |
| isTransformed | back to summary |
|---|---|
| public boolean isTransformed() Indicates whether or not this
| |
| usesFractionalMetrics | back to summary |
|---|---|
| public boolean usesFractionalMetrics() Returns a boolean which whether text fractional metrics mode
is used in this
| |