The TextAttribute class defines attribute keys and
attribute values used for text rendering.
TextAttribute instances are used as attribute keys to
identify attributes in
Font ,
TextLayout ,
AttributedCharacterIterator ,
and other classes handling text attributes. Other constants defined
in this class can be used as attribute values.
For each text attribute, the documentation provides:
the type of its value,
the relevant predefined constants, if any
the default effect if the attribute is absent
the valid values if there are limitations
a description of the effect.
Values
The values of attributes must always be immutable.
Where value limitations are given, any value outside of that
set is reserved for future use; the value will be treated as
the default.
The value null is treated the same as the
default value and results in the default behavior.
If the value is not of the proper type, the attribute
will be ignored.
The identity of the value does not matter, only the actual
value. For example, TextAttribute.WEIGHT_BOLD and
new Float(2.0)
indicate the same WEIGHT.
Attribute values of type Number (used for
WEIGHT, WIDTH, POSTURE,
SIZE, JUSTIFICATION, and
TRACKING) can vary along their natural range and are
not restricted to the predefined constants.
Number.floatValue() is used to get the actual value
from the Number.
The values for WEIGHT, WIDTH, and
POSTURE are interpolated by the system, which
can select the 'nearest available' font or use other techniques to
approximate the user's request.
TextAttributeclass defines attribute keys and attribute values used for text rendering.TextAttributeinstances are used as attribute keys to identify attributes in Font , TextLayout , AttributedCharacterIterator , and other classes handling text attributes. Other constants defined in this class can be used as attribute values.For each text attribute, the documentation provides:
Values
nullis treated the same as the default value and results in the default behavior.TextAttribute.WEIGHT_BOLDandnew Float(2.0)indicate the sameWEIGHT.Number(used forWEIGHT,WIDTH,POSTURE,SIZE,JUSTIFICATION, andTRACKING) can vary along their natural range and are not restricted to the predefined constants.Number.floatValue()is used to get the actual value from theNumber.WEIGHT,WIDTH, andPOSTUREare interpolated by the system, which can select the 'nearest available' font or use other techniques to approximate the user's request.Summary of attributes
SERIF , SANS_SERIF , and MONOSPACED .
WIDTH_EXTENDED
RUN_DIRECTION_RTL
Annotation
UNDERLINE_LOW_TWO_PIXEL