src/java.desktop/share/classes/java/awt/font/TextAttribute.java

Print this page




 627      * <code>Font</code> from attributes should be performed.
 628      *
 629      * <p><code>TextLayout</code> and
 630      * <code>AttributedCharacterIterator</code> work in terms of
 631      * <code>Maps</code> of <code>TextAttributes</code>.  Normally,
 632      * all the attributes are examined and used to select and
 633      * configure a <code>Font</code> instance.  If a <code>FONT</code>
 634      * attribute is present, though, its associated <code>Font</code>
 635      * will be used.  This provides a way for users to override the
 636      * resolution of font attributes into a <code>Font</code>, or
 637      * force use of a particular <code>Font</code> instance.  This
 638      * also allows users to specify subclasses of <code>Font</code> in
 639      * cases where a <code>Font</code> can be subclassed.
 640      *
 641      * <p><code>FONT</code> is used for special situations where
 642      * clients already have a <code>Font</code> instance but still
 643      * need to use <code>Map</code>-based APIs.  Typically, there will
 644      * be no other attributes in the <code>Map</code> except the
 645      * <code>FONT</code> attribute.  With <code>Map</code>-based APIs
 646      * the common case is to specify all attributes individually, so
 647      * <code>FONT</code> is not needed or desireable.
 648      *
 649      * <p>However, if both <code>FONT</code> and other attributes are
 650      * present in the <code>Map</code>, the rendering system will
 651      * merge the attributes defined in the <code>Font</code> with the
 652      * additional attributes.  This merging process classifies
 653      * <code>TextAttributes</code> into two groups.  One group, the
 654      * 'primary' group, is considered fundamental to the selection and
 655      * metric behavior of a font.  These attributes are
 656      * <code>FAMILY</code>, <code>WEIGHT</code>, <code>WIDTH</code>,
 657      * <code>POSTURE</code>, <code>SIZE</code>,
 658      * <code>TRANSFORM</code>, <code>SUPERSCRIPT</code>, and
 659      * <code>TRACKING</code>. The other group, the 'secondary' group,
 660      * consists of all other defined attributes, with the exception of
 661      * <code>FONT</code> itself.
 662      *
 663      * <p>To generate the new <code>Map</code>, first the
 664      * <code>Font</code> is obtained from the <code>FONT</code>
 665      * attribute, and <em>all</em> of its attributes extracted into a
 666      * new <code>Map</code>.  Then only the <em>secondary</em>
 667      * attributes from the original <code>Map</code> are added to


 669      * attributes come solely from the <code>Font</code>, and the
 670      * values of secondary attributes originate with the
 671      * <code>Font</code> but can be overridden by other values in the
 672      * <code>Map</code>.
 673      *
 674      * <p><em>Note:</em><code>Font's</code> <code>Map</code>-based
 675      * constructor and <code>deriveFont</code> methods do not process
 676      * the <code>FONT</code> attribute, as these are used to create
 677      * new <code>Font</code> objects.  Instead, {@link
 678      * java.awt.Font#getFont(Map) Font.getFont(Map)} should be used to
 679      * handle the <code>FONT</code> attribute.
 680      *
 681      * @see java.awt.Font
 682      */
 683     public static final TextAttribute FONT =
 684         new TextAttribute("font");
 685 
 686     /**
 687      * Attribute key for a user-defined glyph to display in lieu
 688      * of the font's standard glyph for a character.  Values are
 689      * intances of GraphicAttribute.  The default value is null,
 690      * indicating that the standard glyphs provided by the font
 691      * should be used.
 692      *
 693      * <p>This attribute is used to reserve space for a graphic or
 694      * other component embedded in a line of text.  It is required for
 695      * correct positioning of 'inline' components within a line when
 696      * bidirectional reordering (see {@link java.text.Bidi}) is
 697      * performed.  Each character (Unicode code point) will be
 698      * rendered using the provided GraphicAttribute. Typically, the
 699      * characters to which this attribute is applied should be
 700      * <code>&#92;uFFFC</code>.
 701      *
 702      * <p>The GraphicAttribute determines the logical and visual
 703      * bounds of the text; the actual Font values are ignored.
 704      *
 705      * @see GraphicAttribute
 706      */
 707     public static final TextAttribute CHAR_REPLACEMENT =
 708         new TextAttribute("char_replacement");
 709 


1081      * @see #LIGATURES
1082      * @since 1.6
1083      */
1084     public static final Integer LIGATURES_ON =
1085         Integer.valueOf(1);
1086 
1087     /**
1088      * Attribute key to control tracking.  Values are instances of
1089      * <b><code>Number</code></b>.  The default value is
1090      * <code>0</code>, which means no additional tracking.
1091      *
1092      * <p>The constant values {@link #TRACKING_TIGHT} and {@link
1093      * #TRACKING_LOOSE} are provided.
1094      *
1095      * <p>The tracking value is multiplied by the font point size and
1096      * passed through the font transform to determine an additional
1097      * amount to add to the advance of each glyph cluster.  Positive
1098      * tracking values will inhibit formation of optional ligatures.
1099      * Tracking values are typically between <code>-0.1</code> and
1100      * <code>0.3</code>; values outside this range are generally not
1101      * desireable.
1102      *
1103      * @since 1.6
1104      */
1105     public static final TextAttribute TRACKING =
1106         new TextAttribute("tracking");
1107 
1108     /**
1109      * Perform tight tracking.
1110      * @see #TRACKING
1111      * @since 1.6
1112      */
1113     public static final Float TRACKING_TIGHT =
1114         Float.valueOf(-.04f);
1115 
1116     /**
1117      * Perform loose tracking.
1118      * @see #TRACKING
1119      * @since 1.6
1120      */
1121     public static final Float TRACKING_LOOSE =


 627      * <code>Font</code> from attributes should be performed.
 628      *
 629      * <p><code>TextLayout</code> and
 630      * <code>AttributedCharacterIterator</code> work in terms of
 631      * <code>Maps</code> of <code>TextAttributes</code>.  Normally,
 632      * all the attributes are examined and used to select and
 633      * configure a <code>Font</code> instance.  If a <code>FONT</code>
 634      * attribute is present, though, its associated <code>Font</code>
 635      * will be used.  This provides a way for users to override the
 636      * resolution of font attributes into a <code>Font</code>, or
 637      * force use of a particular <code>Font</code> instance.  This
 638      * also allows users to specify subclasses of <code>Font</code> in
 639      * cases where a <code>Font</code> can be subclassed.
 640      *
 641      * <p><code>FONT</code> is used for special situations where
 642      * clients already have a <code>Font</code> instance but still
 643      * need to use <code>Map</code>-based APIs.  Typically, there will
 644      * be no other attributes in the <code>Map</code> except the
 645      * <code>FONT</code> attribute.  With <code>Map</code>-based APIs
 646      * the common case is to specify all attributes individually, so
 647      * <code>FONT</code> is not needed or desirable.
 648      *
 649      * <p>However, if both <code>FONT</code> and other attributes are
 650      * present in the <code>Map</code>, the rendering system will
 651      * merge the attributes defined in the <code>Font</code> with the
 652      * additional attributes.  This merging process classifies
 653      * <code>TextAttributes</code> into two groups.  One group, the
 654      * 'primary' group, is considered fundamental to the selection and
 655      * metric behavior of a font.  These attributes are
 656      * <code>FAMILY</code>, <code>WEIGHT</code>, <code>WIDTH</code>,
 657      * <code>POSTURE</code>, <code>SIZE</code>,
 658      * <code>TRANSFORM</code>, <code>SUPERSCRIPT</code>, and
 659      * <code>TRACKING</code>. The other group, the 'secondary' group,
 660      * consists of all other defined attributes, with the exception of
 661      * <code>FONT</code> itself.
 662      *
 663      * <p>To generate the new <code>Map</code>, first the
 664      * <code>Font</code> is obtained from the <code>FONT</code>
 665      * attribute, and <em>all</em> of its attributes extracted into a
 666      * new <code>Map</code>.  Then only the <em>secondary</em>
 667      * attributes from the original <code>Map</code> are added to


 669      * attributes come solely from the <code>Font</code>, and the
 670      * values of secondary attributes originate with the
 671      * <code>Font</code> but can be overridden by other values in the
 672      * <code>Map</code>.
 673      *
 674      * <p><em>Note:</em><code>Font's</code> <code>Map</code>-based
 675      * constructor and <code>deriveFont</code> methods do not process
 676      * the <code>FONT</code> attribute, as these are used to create
 677      * new <code>Font</code> objects.  Instead, {@link
 678      * java.awt.Font#getFont(Map) Font.getFont(Map)} should be used to
 679      * handle the <code>FONT</code> attribute.
 680      *
 681      * @see java.awt.Font
 682      */
 683     public static final TextAttribute FONT =
 684         new TextAttribute("font");
 685 
 686     /**
 687      * Attribute key for a user-defined glyph to display in lieu
 688      * of the font's standard glyph for a character.  Values are
 689      * instances of GraphicAttribute.  The default value is null,
 690      * indicating that the standard glyphs provided by the font
 691      * should be used.
 692      *
 693      * <p>This attribute is used to reserve space for a graphic or
 694      * other component embedded in a line of text.  It is required for
 695      * correct positioning of 'inline' components within a line when
 696      * bidirectional reordering (see {@link java.text.Bidi}) is
 697      * performed.  Each character (Unicode code point) will be
 698      * rendered using the provided GraphicAttribute. Typically, the
 699      * characters to which this attribute is applied should be
 700      * <code>&#92;uFFFC</code>.
 701      *
 702      * <p>The GraphicAttribute determines the logical and visual
 703      * bounds of the text; the actual Font values are ignored.
 704      *
 705      * @see GraphicAttribute
 706      */
 707     public static final TextAttribute CHAR_REPLACEMENT =
 708         new TextAttribute("char_replacement");
 709 


1081      * @see #LIGATURES
1082      * @since 1.6
1083      */
1084     public static final Integer LIGATURES_ON =
1085         Integer.valueOf(1);
1086 
1087     /**
1088      * Attribute key to control tracking.  Values are instances of
1089      * <b><code>Number</code></b>.  The default value is
1090      * <code>0</code>, which means no additional tracking.
1091      *
1092      * <p>The constant values {@link #TRACKING_TIGHT} and {@link
1093      * #TRACKING_LOOSE} are provided.
1094      *
1095      * <p>The tracking value is multiplied by the font point size and
1096      * passed through the font transform to determine an additional
1097      * amount to add to the advance of each glyph cluster.  Positive
1098      * tracking values will inhibit formation of optional ligatures.
1099      * Tracking values are typically between <code>-0.1</code> and
1100      * <code>0.3</code>; values outside this range are generally not
1101      * desirable.
1102      *
1103      * @since 1.6
1104      */
1105     public static final TextAttribute TRACKING =
1106         new TextAttribute("tracking");
1107 
1108     /**
1109      * Perform tight tracking.
1110      * @see #TRACKING
1111      * @since 1.6
1112      */
1113     public static final Float TRACKING_TIGHT =
1114         Float.valueOf(-.04f);
1115 
1116     /**
1117      * Perform loose tracking.
1118      * @see #TRACKING
1119      * @since 1.6
1120      */
1121     public static final Float TRACKING_LOOSE =