java.lang.Object | ||
↳ | java.awt.font.GlyphVector | |
↳ | sun.font.StandardGlyphVector |
Standard implementation of GlyphVector used by Font, GlyphList, and SunGraphics2D. The main issues involve the semantics of the various transforms (font, glyph, device) and their effect on rendering and metrics. Very, very unfortunately, the translation component of the font transform affects where the text gets rendered. It offsets the rendering origin. None of the other metrics of the glyphvector are affected, making them inconsistent with the rendering behavior. I think the translation component of the font would be better interpreted as the translation component of a per-glyph transform, but I don't know if this is possible to change. After the font transform is applied, the glyph transform is applied. This makes glyph transforms relative to font transforms, if the font transform changes, the glyph transform will have the same (relative) effect on the outline of the glyph. The outline and logical bounds are passed through the glyph transform before being returned. The glyph metrics ignore the glyph transform, but provide the outline bounds and the advance vector of the glyph (the latter will be rotated if the font is rotated). The default layout places each glyph at the end of the advance vector of the previous glyph, and since the glyph transform translates the advance vector, this means a glyph transform affects the positions of all subsequent glyphs if defaultLayout is called after setting a glyph transform. In the glyph info array, the bounds are the outline bounds including the glyph transform, and the positions are as computed, and the advances are the deltas between the positions. (There's a bug in the logical bounds of a rotated glyph for composite fonts, it's not to spec (in 1.4.0, 1.4.1, 1.4.2). The problem is that the rotated composite doesn't handle the multiple ascents and descents properly in both x and y. You end up with a rotated advance vector but an unrotated ascent and descent.) Finally, the whole thing is transformed by the device transform to position it on the page. Another bug: The glyph outline seems to ignore fractional point size information, but the images (and advances) don't ignore it. Small fonts drawn at large magnification have odd advances when fractional metrics is off-- that's because the advances depend on the frc. When the frc is scaled appropriately, the advances are fine. FM or a large frc (high numbers) make the advances right. The buffer aa flag doesn't affect rendering, the glyph vector renders as AA if aa is set in its frc, and as non-aa if aa is not set in its frc. font rotation, baseline, vertical etc. Font rotation and baseline Line metrics should be measured along a unit vector pi/4 cc from the baseline vector. For 'horizontal' fonts the baseline vector is the x vector passed through the font transform (ignoring translation), for 'vertical' it is the y vector. This definition makes ascent, descent, etc independent of shear, so shearing can be used to simulate italic. This means no fonts have 'negative ascents' or 'zero ascents' etc. Having a coordinate system with orthogonal axes where one is parallel to the baseline means we could use rectangles and interpret them in terms of this coordinate system. Unfortunately there is support for rotated fonts in the jdk already so maintaining the semantics of existing code (getlogical bounds, etc) might be difficult. A font transform transforms both the baseline and all the glyphs in the font, so it does not rotate the glyph w.r.t the baseline. If you do want to rotate individual glyphs, you need to apply a glyph transform. If performDefaultLayout is called after this, the transformed glyph advances will affect the glyph positions. useful additions - select vertical metrics - glyphs are rotated pi/4 cc and vertical metrics are used to align them to the baseline. - define baseline for font (glyph rotation not linked to baseline) - define extra space (delta between each glyph along baseline) - define offset (delta from 'true' baseline, impacts ascent and descent as these are still computed from true basline and pinned to zero, used in superscript).
Nested Classes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
StandardGlyphVector.GlyphStrike |
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
int | FLAG_USES_ALTERNATE_ORIENTATION | A flag used with getLayoutFlags that indicates whether this GlyphVector uses
the 'alternate orientation.' Glyphs have a default orientation given a
particular baseline and metrics orientation, this is the orientation appropriate
for left-to-right text. |
|||||||||
int | FLAG_USES_VERTICAL_BASELINE | A flag used with getLayoutFlags that indicates whether this GlyphVector uses
a vertical baseline. |
|||||||||
int | FLAG_USES_VERTICAL_METRICS | A flag used with getLayoutFlags that indicates whether this GlyphVector uses
vertical glyph metrics. |
[Expand]
Inherited Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
As a concrete subclass of GlyphVector, this must implement clone.
| |||||||||||
Sometimes I wish java had covariant return types...
| |||||||||||
Since we implement equality comparisons for GlyphVector, we implement
the inherited Object.equals(Object) as well.
| |||||||||||
Tests if the specified
GlyphVector exactly
equals this GlyphVector . | |||||||||||
Returns the
Font associated with this
GlyphVector . | |||||||||||
Returns the
FontRenderContext associated with this
GlyphVector . | |||||||||||
Returns the character index of the specified glyph.
| |||||||||||
Returns the character indices of the specified glyphs.
| |||||||||||
Returns the glyphcode of the specified glyph.
| |||||||||||
Returns an array of glyphcodes for the specified glyphs.
| |||||||||||
For each glyph return posx, posy, advx, advy, visx, visy, visw, vish.
| |||||||||||
Returns the justification information for the glyph at
the specified index into this
GlyphVector . | |||||||||||
Returns the logical bounds of the specified glyph within this
GlyphVector . | |||||||||||
Returns the metrics of the glyph at the specified index into
this
GlyphVector . | |||||||||||
Returns a
Shape whose interior corresponds to the
visual representation of the specified glyph
within this GlyphVector . | |||||||||||
Returns a
Shape whose interior corresponds to the
visual representation of the specified glyph
within this GlyphVector , offset to x, y. | |||||||||||
Returns the pixel bounds of the glyph at index when this
GlyphVector is rendered in a Graphics with the
given FontRenderContext at the given location. | |||||||||||
Returns the position of the specified glyph relative to the
origin of this
GlyphVector . | |||||||||||
Returns an array of glyph positions for the specified glyphs.
| |||||||||||
This is a convenience overload that gets all the glyph positions, which
is what you usually want to do if you're getting more than one.
| |||||||||||
Returns the transform of the specified glyph within this
GlyphVector . | |||||||||||
Get transform information for the requested range of glyphs.
| |||||||||||
Convenience overload for getGlyphTransforms(int, int, AffineTransform[], int);
| |||||||||||
Returns the visual bounds of the specified glyph within the
GlyphVector . | |||||||||||
Returns flags describing the global state of the GlyphVector.
| |||||||||||
Returns the logical bounds of this
GlyphVector . | |||||||||||
Returns the number of glyphs in this
GlyphVector . | |||||||||||
Returns a
Shape whose interior corresponds to the
visual representation of this GlyphVector . | |||||||||||
Returns a
Shape whose interior corresponds to the
visual representation of this GlyphVector when
rendered at x, y. | |||||||||||
Returns the pixel bounds of this
GlyphVector when
rendered in a graphics with the given
FontRenderContext at the given location. | |||||||||||
Returns the visual bounds of this
GlyphVector
The visual bounds is the bounding box of the outline of this
GlyphVector . | |||||||||||
As a concrete subclass of Object that implements equality, this must
implement hashCode.
| |||||||||||
Assigns default positions to each glyph in this
GlyphVector . | |||||||||||
!!! not used currently, but might be by getPixelbounds?
| |||||||||||
Sets the position of the specified glyph within this
GlyphVector . | |||||||||||
Set all the glyph positions, including the 'after last glyph' position.
| |||||||||||
Sets the transform of the specified glyph within this
GlyphVector . | |||||||||||
Set a number of glyph transforms.
| |||||||||||
Convenience overload of setGlyphTransforms(AffineTransform[], int, int, int).
| |||||||||||
Returns a string representation of the object.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() | |||||||||||
![]() |
A flag used with getLayoutFlags that indicates whether this GlyphVector
uses
the 'alternate orientation.' Glyphs have a default orientation given a
particular baseline and metrics orientation, this is the orientation appropriate
for left-to-right text. For example, the letter 'A' can have four orientations,
with the point at 12, 3, 6, or 9 'o clock. The following table shows where the
point displays for different values of vertical baseline (vb), vertical
metrics (vm) and alternate orientation (fo):
vb vm ao -- -- -- -- f f f 12 ^ horizontal metrics on horizontal lines f f t 6 v f t f 9 < vertical metrics on horizontal lines f t t 3 > t f f 3 > horizontal metrics on vertical lines t f t 9 < t t f 12 ^ vertical metrics on vertical lines t t t 6 v
A flag used with getLayoutFlags that indicates whether this GlyphVector
uses
a vertical baseline.
A flag used with getLayoutFlags that indicates whether this GlyphVector
uses
vertical glyph metrics. A GlyphVector
can use vertical metrics on a
horizontal line, or vice versa.
As a concrete subclass of GlyphVector, this must implement clone.
Since we implement equality comparisons for GlyphVector, we implement the inherited Object.equals(Object) as well. GlyphVector should do this, and define two glyphvectors as not equal if the classes differ.
rhs | the reference object with which to compare. |
---|
true
if this object is the same as the obj
argument; false
otherwise.Tests if the specified GlyphVector
exactly
equals this GlyphVector
.
rhs | the specified GlyphVector to test |
---|
true
if the specified
GlyphVector
equals this GlyphVector
;
false
otherwise.
Returns the Font
associated with this
GlyphVector
.
Font
used to create this
GlyphVector
.Returns the FontRenderContext
associated with this
GlyphVector
.
FontRenderContext
used to create this
GlyphVector
.Returns the character index of the specified glyph. The character index is the index of the first logical character represented by the glyph. The default implementation assumes a one-to-one, left-to-right mapping of glyphs to characters.
ix | the index of the glyph |
---|
Returns the character indices of the specified glyphs. The character index is the index of the first logical character represented by the glyph. Indices are returned in glyph order. The default implementation invokes getGlyphCharIndex for each glyph, and subclassers will probably want to override this implementation for performance reasons. Use this method for convenience and performance in processing of glyphcodes. If no array is passed in, a new array is created.
start | the index of the first glyph |
---|---|
count | the number of glyph indices |
result | the array into which to return the character indices |
Returns the glyphcode of the specified glyph.
This return value is meaningless to anything other
than the Font
object that created this
GlyphVector
.
glyphIndex | the index into this GlyphVector
that corresponds to the glyph from which to retrieve the
glyphcode. |
---|
glyphIndex
.Returns an array of glyphcodes for the specified glyphs.
The contents of this return value are meaningless to anything other
than the Font
used to create this
GlyphVector
. This method is used
for convenience and performance when processing glyphcodes.
If no array is passed in, a new array is created.
start | the index into this
GlyphVector at which to start retrieving glyphcodes |
---|---|
count | the number of glyphcodes to retrieve |
result | the array that receives the glyphcodes and is then returned |
For each glyph return posx, posy, advx, advy, visx, visy, visw, vish.
Returns the justification information for the glyph at
the specified index into this GlyphVector
.
ix | the index into this GlyphVector
that corresponds to the glyph from which to retrieve its
justification properties |
---|
GlyphJustificationInfo
object that
represents the justification properties of the glyph at the
specified glyphIndex
into this
GlyphVector
.Returns the logical bounds of the specified glyph within this
GlyphVector
.
These logical bounds have a total of four edges, with two edges
parallel to the baseline under the glyph's transform and the other two
edges are shared with adjacent glyphs if they are present. This
method is useful for hit-testing of the specified glyph,
positioning of a caret at the leading or trailing edge of a glyph,
and for drawing a highlight region around the specified glyph.
ix | the index into this GlyphVector
that corresponds to the glyph from which to retrieve its logical
bounds |
---|
Shape
that is the logical bounds of the
glyph at the specified glyphIndex
.Returns the metrics of the glyph at the specified index into
this GlyphVector
.
ix | the index into this GlyphVector
that corresponds to the glyph from which to retrieve its metrics |
---|
GlyphMetrics
object that represents the
metrics of the glyph at the specified glyphIndex
into this GlyphVector
.Returns a Shape
whose interior corresponds to the
visual representation of the specified glyph
within this GlyphVector
.
The outline returned by this method is positioned around the
origin of each individual glyph.
ix | the index into this GlyphVector |
---|
Shape
that is the outline of the glyph
at the specified glyphIndex
of this
GlyphVector
.Returns a Shape
whose interior corresponds to the
visual representation of the specified glyph
within this GlyphVector
, offset to x, y.
The outline returned by this method is positioned around the
origin of each individual glyph.
ix | the index into this GlyphVector |
---|---|
x | the X coordinate of the location of this GlyphVector |
y | the Y coordinate of the location of this GlyphVector |
Shape
that is the outline of the glyph
at the specified glyphIndex
of this
GlyphVector
when rendered at the specified
coordinates.Returns the pixel bounds of the glyph at index when this
GlyphVector
is rendered in a Graphics
with the
given FontRenderContext
at the given location. The
renderFRC need not be the same as the
FontRenderContext
of this
GlyphVector
, and can be null. If it is null, the
FontRenderContext
of this GlyphVector
is used. The default implementation returns the visual bounds of the glyph,
offset to x, y and rounded out to the next integer value, and
ignores the FRC. Subclassers should override this method.
index | the index of the glyph. |
---|---|
renderFRC | the FontRenderContext of the Graphics . |
x | the X position at which to render this GlyphVector . |
y | the Y position at which to render this GlyphVector . |
Rectangle
bounding the pixels that would be affected.Returns the position of the specified glyph relative to the
origin of this GlyphVector
.
If glyphIndex
equals the number of of glyphs in
this GlyphVector
, this method returns the position after
the last glyph. This position is used to define the advance of
the entire GlyphVector
.
ix | the index into this GlyphVector |
---|
Point2D
object that is the position of the glyph
at the specified glyphIndex
.Returns an array of glyph positions for the specified glyphs.
This method is used for convenience and performance when
processing glyph positions.
If no array is passed in, a new array is created.
Even numbered array entries beginning with position zero are the X
coordinates of the glyph numbered beginGlyphIndex + position/2
.
Odd numbered array entries beginning with position one are the Y
coordinates of the glyph numbered beginGlyphIndex + (position-1)/2
.
If beginGlyphIndex
equals the number of of glyphs in
this GlyphVector
, this method gets the position after
the last glyph and this position is used to define the advance of
the entire GlyphVector
.
start | the index at which to begin retrieving glyph positions |
---|---|
count | the number of glyphs to retrieve |
result | the array that receives the glyph positions and is then returned. |
beginGlyphIndex
and numEntries
.This is a convenience overload that gets all the glyph positions, which is what you usually want to do if you're getting more than one. !!! should I bother taking result parameter?
Returns the transform of the specified glyph within this
GlyphVector
. The transform is relative to the
glyph position. If no special transform has been applied,
null
can be returned. A null return indicates
an identity transform.
ix | the index into this GlyphVector |
---|
AffineTransform
that is the transform of
the glyph at the specified glyphIndex
.Get transform information for the requested range of glyphs. If no glyphs have a transform, return null. If a glyph has no transform (or is the identity transform) its entry in the result array will be null. If the passed-in result is null an array will be allocated for the caller. Each transform instance in the result array will unique, and independent of the GlyphVector's transform.
Convenience overload for getGlyphTransforms(int, int, AffineTransform[], int);
Returns the visual bounds of the specified glyph within the
GlyphVector
.
The bounds returned by this method is positioned around the
origin of each individual glyph.
ix | the index into this GlyphVector
that corresponds to the glyph from which to retrieve its visual
bounds |
---|
Shape
that is the visual bounds of the
glyph at the specified glyphIndex
.Returns flags describing the global state of the GlyphVector. Flags not described below are reserved. The default implementation returns 0 (meaning false) for the position adjustments, transforms, rtl, and complex flags. Subclassers should override this method, and make sure it correctly describes the GlyphVector and corresponds to the results of related calls.
Returns the logical bounds of this GlyphVector
.
This method is used when positioning this GlyphVector
in relation to visually adjacent GlyphVector
objects.
Rectangle2D
that is the logical bounds of this
GlyphVector
.
Returns the number of glyphs in this GlyphVector
.
GlyphVector
.
Returns a Shape
whose interior corresponds to the
visual representation of this GlyphVector
.
Shape
that is the outline of this
GlyphVector
.
Returns a Shape
whose interior corresponds to the
visual representation of this GlyphVector
when
rendered at x, y.
x | the X coordinate of this GlyphVector . |
---|---|
y | the Y coordinate of this GlyphVector . |
Shape
that is the outline of this
GlyphVector
when rendered at the specified
coordinates.
Returns the pixel bounds of this GlyphVector
when
rendered in a graphics with the given
FontRenderContext
at the given location. The
renderFRC need not be the same as the
FontRenderContext
of this
GlyphVector
, and can be null. If it is null, the
FontRenderContext
of this GlyphVector
is used. The default implementation returns the visual bounds,
offset to x, y and rounded out to the next integer value (i.e. returns an
integer rectangle which encloses the visual bounds) and
ignores the FRC. Subclassers should override this method.
renderFRC | the FontRenderContext of the Graphics . |
---|---|
x | the x-coordinate at which to render this GlyphVector . |
y | the y-coordinate at which to render this GlyphVector . |
Rectangle
bounding the pixels that would be affected.Returns the visual bounds of this GlyphVector
The visual bounds is the bounding box of the outline of this
GlyphVector
. Because of rasterization and
alignment of pixels, it is possible that this box does not
enclose all pixels affected by rendering this GlyphVector
.
Rectangle2D
that is the bounding box
of this GlyphVector
.
As a concrete subclass of Object that implements equality, this must implement hashCode.
Assigns default positions to each glyph in this
GlyphVector
. This can destroy information
generated during initial layout of this GlyphVector
.
!!! not used currently, but might be by getPixelbounds?
Sets the position of the specified glyph within this
GlyphVector
.
If glyphIndex
equals the number of of glyphs in
this GlyphVector
, this method sets the position after
the last glyph. This position is used to define the advance of
the entire GlyphVector
.
ix | the index into this GlyphVector |
---|---|
pos | the Point2D at which to position the
glyph at the specified glyphIndex |
Set all the glyph positions, including the 'after last glyph' position. The srcPositions array must be of length (numGlyphs + 1) * 2.
Sets the transform of the specified glyph within this
GlyphVector
. The transform is relative to the glyph
position. A null
argument for newTX
indicates that no special transform is applied for the specified
glyph.
This method can be used to rotate, mirror, translate and scale the
glyph. Adding a transform can result in signifant performance changes.
ix | the index into this GlyphVector |
---|---|
newTX | the new transform of the glyph at glyphIndex |
Set a number of glyph transforms. Original transforms are unchanged. The array may contain nulls, and also may contain multiple references to the same transform instance.
Convenience overload of setGlyphTransforms(AffineTransform[], int, int, int).
Returns a string representation of the object. In general, the
toString
method returns a string that
"textually represents" this object. The result should
be a concise but informative representation that is easy for a
person to read.
It is recommended that all subclasses override this method.
The toString
method for class Object
returns a string consisting of the name of the class of which the
object is an instance, the at-sign character `@
', and
the unsigned hexadecimal representation of the hash code of the
object. In other words, this method returns a string equal to the
value of:
getClass().getName() + '@' + Integer.toHexString(hashCode())