0N/A/*
2362N/A * Copyright (c) 1997, 2006, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/A/*
0N/A * (C) Copyright Taligent, Inc. 1996 - 1997, All Rights Reserved
0N/A * (C) Copyright IBM Corp. 1996 - 1998, All Rights Reserved
0N/A *
0N/A * The original version of this source code and documentation is
0N/A * copyrighted and owned by Taligent, Inc., a wholly-owned subsidiary
0N/A * of IBM. These materials are provided under terms of a License
0N/A * Agreement between Taligent and Sun. This technology is protected
0N/A * by multiple US and International patents.
0N/A *
0N/A * This notice and attribution to Taligent may not be removed.
0N/A * Taligent is a registered trademark of Taligent, Inc.
0N/A *
0N/A */
0N/A
0N/Apackage java.awt.font;
0N/A
0N/Aimport java.io.InvalidObjectException;
0N/Aimport java.text.AttributedCharacterIterator.Attribute;
0N/Aimport java.util.Map;
0N/Aimport java.util.HashMap;
0N/A
0N/A/**
0N/A * The <code>TextAttribute</code> class defines attribute keys and
0N/A * attribute values used for text rendering.
0N/A * <p>
0N/A * <code>TextAttribute</code> instances are used as attribute keys to
0N/A * identify attributes in
0N/A * {@link java.awt.Font Font},
0N/A * {@link java.awt.font.TextLayout TextLayout},
0N/A * {@link java.text.AttributedCharacterIterator AttributedCharacterIterator},
0N/A * and other classes handling text attributes. Other constants defined
0N/A * in this class can be used as attribute values.
0N/A * <p>
0N/A * For each text attribute, the documentation provides:
0N/A * <UL>
0N/A * <LI>the type of its value,
0N/A * <LI>the relevant predefined constants, if any
0N/A * <LI>the default effect if the attribute is absent
0N/A * <LI>the valid values if there are limitations
0N/A * <LI>a description of the effect.
0N/A * </UL>
0N/A * <p>
0N/A * <H4>Values</H4>
0N/A * <UL>
0N/A * <LI>The values of attributes must always be immutable.
0N/A * <LI>Where value limitations are given, any value outside of that
0N/A * set is reserved for future use; the value will be treated as
0N/A * the default.
0N/A * <LI>The value <code>null</code> is treated the same as the
0N/A * default value and results in the default behavior.
0N/A * <li>If the value is not of the proper type, the attribute
0N/A * will be ignored.
0N/A * <li>The identity of the value does not matter, only the actual
0N/A * value. For example, <code>TextAttribute.WEIGHT_BOLD</code> and
0N/A * <code>new Float(2.0)</code>
0N/A * indicate the same <code>WEIGHT</code>.
0N/A * <li>Attribute values of type <code>Number</code> (used for
0N/A * <code>WEIGHT</code>, <code>WIDTH</code>, <code>POSTURE</code>,
0N/A * <code>SIZE</code>, <code>JUSTIFICATION</code>, and
0N/A * <code>TRACKING</code>) can vary along their natural range and are
0N/A * not restricted to the predefined constants.
0N/A * <code>Number.floatValue()</code> is used to get the actual value
0N/A * from the <code>Number</code>.
0N/A * <li>The values for <code>WEIGHT</code>, <code>WIDTH</code>, and
0N/A * <code>POSTURE</code> are interpolated by the system, which
0N/A * can select the 'nearest available' font or use other techniques to
0N/A * approximate the user's request.
0N/A *
0N/A * </UL>
0N/A *
0N/A * <h4>Summary of attributes</h4>
0N/A * <p>
0N/A * <font size="-1">
0N/A * <table align="center" border="0" cellspacing="0" cellpadding="2" width="%95"
0N/A * summary="Key, value type, principal constants, and default value
0N/A * behavior of all TextAttributes">
0N/A * <tr bgcolor="#ccccff">
0N/A * <th valign="TOP" align="CENTER">Key</th>
0N/A * <th valign="TOP" align="CENTER">Value Type</th>
0N/A * <th valign="TOP" align="CENTER">Principal Constants</th>
0N/A * <th valign="TOP" align="CENTER">Default Value</th>
0N/A * </tr>
0N/A * <tr>
0N/A * <td valign="TOP">{@link #FAMILY}</td>
0N/A * <td valign="TOP">String</td>
0N/A * <td valign="TOP">See Font {@link java.awt.Font#DIALOG DIALOG},
0N/A{@link java.awt.Font#DIALOG_INPUT DIALOG_INPUT},<br> {@link java.awt.Font#SERIF SERIF},
0N/A{@link java.awt.Font#SANS_SERIF SANS_SERIF}, and {@link java.awt.Font#MONOSPACED MONOSPACED}.
0N/A</td>
0N/A * <td valign="TOP">"Default" (use platform default)</td>
0N/A * </tr>
0N/A * <tr bgcolor="#eeeeff">
0N/A * <td valign="TOP">{@link #WEIGHT}</td>
0N/A * <td valign="TOP">Number</td>
0N/A * <td valign="TOP">WEIGHT_REGULAR, WEIGHT_BOLD</td>
0N/A * <td valign="TOP">WEIGHT_REGULAR</td>
0N/A * </tr>
0N/A * <tr>
0N/A * <td valign="TOP">{@link #WIDTH}</td>
0N/A * <td valign="TOP">Number</td>
0N/A * <td valign="TOP">WIDTH_CONDENSED, WIDTH_REGULAR,<br>WIDTH_EXTENDED</td>
0N/A * <td valign="TOP">WIDTH_REGULAR</td>
0N/A * </tr>
0N/A * <tr bgcolor="#eeeeff">
0N/A * <td valign="TOP">{@link #POSTURE}</td>
0N/A * <td valign="TOP">Number</td>
0N/A * <td valign="TOP">POSTURE_REGULAR, POSTURE_OBLIQUE</td>
0N/A * <td valign="TOP">POSTURE_REGULAR</td>
0N/A * </tr>
0N/A * <tr>
0N/A * <td valign="TOP">{@link #SIZE}</td>
0N/A * <td valign="TOP">Number</td>
0N/A * <td valign="TOP">none</td>
0N/A * <td valign="TOP">12.0</td>
0N/A * </tr>
0N/A * <tr bgcolor="#eeeeff">
0N/A * <td valign="TOP">{@link #TRANSFORM}</td>
0N/A * <td valign="TOP">{@link TransformAttribute}</td>
0N/A * <td valign="TOP">See TransformAttribute {@link TransformAttribute#IDENTITY IDENTITY}</td>
0N/A * <td valign="TOP">TransformAttribute.IDENTITY</td>
0N/A * </tr>
0N/A * <tr>
0N/A * <td valign="TOP">{@link #SUPERSCRIPT}</td>
0N/A * <td valign="TOP">Integer</td>
0N/A * <td valign="TOP">SUPERSCRIPT_SUPER, SUPERSCRIPT_SUB</td>
0N/A * <td valign="TOP">0 (use the standard glyphs and metrics)</td>
0N/A * </tr>
0N/A * <tr bgcolor="#eeeeff">
0N/A * <td valign="TOP">{@link #FONT}</td>
0N/A * <td valign="TOP">{@link java.awt.Font}</td>
0N/A * <td valign="TOP">none</td>
0N/A * <td valign="TOP">null (do not override font resolution)</td>
0N/A * </tr>
0N/A * <tr>
0N/A * <td valign="TOP">{@link #CHAR_REPLACEMENT}</td>
0N/A * <td valign="TOP">{@link GraphicAttribute}</td>
0N/A * <td valign="TOP">none</td>
0N/A * <td valign="TOP">null (draw text using font glyphs)</td>
0N/A * </tr>
0N/A * <tr bgcolor="#eeeeff">
0N/A * <td valign="TOP">{@link #FOREGROUND}</td>
0N/A * <td valign="TOP">{@link java.awt.Paint}</td>
0N/A * <td valign="TOP">none</td>
0N/A * <td valign="TOP">null (use current graphics paint)</td>
0N/A * </tr>
0N/A * <tr>
0N/A * <td valign="TOP">{@link #BACKGROUND}</td>
0N/A * <td valign="TOP">{@link java.awt.Paint}</td>
0N/A * <td valign="TOP">none</td>
0N/A * <td valign="TOP">null (do not render background)</td>
0N/A * </tr>
0N/A * <tr bgcolor="#eeeeff">
0N/A * <td valign="TOP">{@link #UNDERLINE}</td>
0N/A * <td valign="TOP">Integer</td>
0N/A * <td valign="TOP">UNDERLINE_ON</td>
0N/A * <td valign="TOP">-1 (do not render underline)</td>
0N/A * </tr>
0N/A * <tr>
0N/A * <td valign="TOP">{@link #STRIKETHROUGH}</td>
0N/A * <td valign="TOP">Boolean</td>
0N/A * <td valign="TOP">STRIKETHROUGH_ON</td>
0N/A * <td valign="TOP">false (do not render strikethrough)</td>
0N/A * </tr>
0N/A * <tr bgcolor="#eeeeff">
0N/A * <td valign="TOP">{@link #RUN_DIRECTION}</td>
0N/A * <td valign="TOP">Boolean</td>
0N/A * <td valign="TOP">RUN_DIRECTION_LTR<br>RUN_DIRECTION_RTL</td>
0N/A * <td valign="TOP">null (use {@link java.text.Bidi} standard default)</td>
0N/A * </tr>
0N/A * <tr>
0N/A * <td valign="TOP">{@link #BIDI_EMBEDDING}</td>
0N/A * <td valign="TOP">Integer</td>
0N/A * <td valign="TOP">none</td>
0N/A * <td valign="TOP">0 (use base line direction)</td>
0N/A * </tr>
0N/A * <tr bgcolor="#eeeeff">
0N/A * <td valign="TOP">{@link #JUSTIFICATION}</td>
0N/A * <td valign="TOP">Number</td>
0N/A * <td valign="TOP">JUSTIFICATION_FULL</td>
0N/A * <td valign="TOP">JUSTIFICATION_FULL</td>
0N/A * </tr>
0N/A * <tr>
0N/A * <td valign="TOP">{@link #INPUT_METHOD_HIGHLIGHT}</td>
0N/A * <td valign="TOP">{@link java.awt.im.InputMethodHighlight},<br>{@link java.text.Annotation}</td>
0N/A * <td valign="TOP">(see class)</td>
0N/A * <td valign="TOP">null (do not apply input highlighting)</td>
0N/A * </tr>
0N/A * <tr bgcolor="#eeeeff">
0N/A * <td valign="TOP">{@link #INPUT_METHOD_UNDERLINE}</td>
0N/A * <td valign="TOP">Integer</td>
0N/A * <td valign="TOP">UNDERLINE_LOW_ONE_PIXEL,<br>UNDERLINE_LOW_TWO_PIXEL</td>
0N/A * <td valign="TOP">-1 (do not render underline)</td>
0N/A * </tr>
0N/A * <tr>
0N/A * <td valign="TOP">{@link #SWAP_COLORS}</td>
0N/A * <td valign="TOP">Boolean</td>
0N/A * <td valign="TOP">SWAP_COLORS_ON</td>
0N/A * <td valign="TOP">false (do not swap colors)</td>
0N/A * </tr>
0N/A * <tr bgcolor="#eeeeff">
0N/A * <td valign="TOP">{@link #NUMERIC_SHAPING}</td>
0N/A * <td valign="TOP">{@link java.awt.font.NumericShaper}</td>
0N/A * <td valign="TOP">none</td>
0N/A * <td valign="TOP">null (do not shape digits)</td>
0N/A * </tr>
0N/A * <tr>
0N/A * <td valign="TOP">{@link #KERNING}</td>
0N/A * <td valign="TOP">Integer</td>
0N/A * <td valign="TOP">KERNING_ON</td>
0N/A * <td valign="TOP">0 (do not request kerning)</td>
0N/A * </tr>
0N/A * <tr bgcolor="#eeeeff">
0N/A * <td valign="TOP">{@link #LIGATURES}</td>
0N/A * <td valign="TOP">Integer</td>
0N/A * <td valign="TOP">LIGATURES_ON</td>
0N/A * <td valign="TOP">0 (do not form optional ligatures)</td>
0N/A * </tr>
0N/A * <tr>
0N/A * <td valign="TOP">{@link #TRACKING}</td>
0N/A * <td valign="TOP">Number</td>
0N/A * <td valign="TOP">TRACKING_LOOSE, TRACKING_TIGHT</td>
0N/A * <td valign="TOP">0 (do not add tracking)</td>
0N/A * </tr>
0N/A * </table>
0N/A * </font>
0N/A *
0N/A * @see java.awt.Font
0N/A * @see java.awt.font.TextLayout
0N/A * @see java.text.AttributedCharacterIterator
0N/A */
0N/Apublic final class TextAttribute extends Attribute {
0N/A
0N/A // table of all instances in this class, used by readResolve
0N/A private static final Map instanceMap = new HashMap(29);
0N/A
0N/A /**
0N/A * Constructs a <code>TextAttribute</code> with the specified name.
0N/A * @param name the attribute name to assign to this
0N/A * <code>TextAttribute</code>
0N/A */
0N/A protected TextAttribute(String name) {
0N/A super(name);
0N/A if (this.getClass() == TextAttribute.class) {
0N/A instanceMap.put(name, this);
0N/A }
0N/A }
0N/A
0N/A /**
0N/A * Resolves instances being deserialized to the predefined constants.
0N/A */
0N/A protected Object readResolve() throws InvalidObjectException {
0N/A if (this.getClass() != TextAttribute.class) {
0N/A throw new InvalidObjectException(
0N/A "subclass didn't correctly implement readResolve");
0N/A }
0N/A
0N/A TextAttribute instance = (TextAttribute) instanceMap.get(getName());
0N/A if (instance != null) {
0N/A return instance;
0N/A } else {
0N/A throw new InvalidObjectException("unknown attribute name");
0N/A }
0N/A }
0N/A
0N/A // Serialization compatibility with Java 2 platform v1.2.
0N/A // 1.2 will throw an InvalidObjectException if ever asked to
0N/A // deserialize INPUT_METHOD_UNDERLINE.
0N/A // This shouldn't happen in real life.
0N/A static final long serialVersionUID = 7744112784117861702L;
0N/A
0N/A //
0N/A // For use with Font.
0N/A //
0N/A
0N/A /**
0N/A * Attribute key for the font name. Values are instances of
0N/A * <b><code>String</code></b>. The default value is
0N/A * <code>"Default"</code>, which causes the platform default font
0N/A * family to be used.
0N/A *
0N/A * <p> The <code>Font</code> class defines constants for the logical
0N/A * font names
0N/A * {@link java.awt.Font#DIALOG DIALOG},
0N/A * {@link java.awt.Font#DIALOG_INPUT DIALOG_INPUT},
0N/A * {@link java.awt.Font#SANS_SERIF SANS_SERIF},
0N/A * {@link java.awt.Font#SERIF SERIF}, and
0N/A * {@link java.awt.Font#MONOSPACED MONOSPACED}.
0N/A *
0N/A * <p>This defines the value passed as <code>name</code> to the
0N/A * <code>Font</code> constructor. Both logical and physical
0N/A * font names are allowed. If a font with the requested name
0N/A * is not found, the default font is used.
0N/A *
0N/A * <p><em>Note:</em> This attribute is unfortunately misnamed, as
0N/A * it specifies the face name and not just the family. Thus
0N/A * values such as "Lucida Sans Bold" will select that face if it
0N/A * exists. Note, though, that if the requested face does not
0N/A * exist, the default will be used with <em>regular</em> weight.
0N/A * The "Bold" in the name is part of the face name, not a separate
0N/A * request that the font's weight be bold.</p>
0N/A */
0N/A public static final TextAttribute FAMILY =
0N/A new TextAttribute("family");
0N/A
0N/A /**
0N/A * Attribute key for the weight of a font. Values are instances
0N/A * of <b><code>Number</code></b>. The default value is
0N/A * <code>WEIGHT_REGULAR</code>.
0N/A *
0N/A * <p>Several constant values are provided, see {@link
0N/A * #WEIGHT_EXTRA_LIGHT}, {@link #WEIGHT_LIGHT}, {@link
0N/A * #WEIGHT_DEMILIGHT}, {@link #WEIGHT_REGULAR}, {@link
0N/A * #WEIGHT_SEMIBOLD}, {@link #WEIGHT_MEDIUM}, {@link
0N/A * #WEIGHT_DEMIBOLD}, {@link #WEIGHT_BOLD}, {@link #WEIGHT_HEAVY},
0N/A * {@link #WEIGHT_EXTRABOLD}, and {@link #WEIGHT_ULTRABOLD}. The
0N/A * value <code>WEIGHT_BOLD</code> corresponds to the
0N/A * style value <code>Font.BOLD</code> as passed to the
0N/A * <code>Font</code> constructor.
0N/A *
0N/A * <p>The value is roughly the ratio of the stem width to that of
0N/A * the regular weight.
0N/A *
0N/A * <p>The system can interpolate the provided value.
0N/A */
0N/A public static final TextAttribute WEIGHT =
0N/A new TextAttribute("weight");
0N/A
0N/A /**
0N/A * The lightest predefined weight.
0N/A * @see #WEIGHT
0N/A */
0N/A public static final Float WEIGHT_EXTRA_LIGHT =
0N/A Float.valueOf(0.5f);
0N/A
0N/A /**
0N/A * The standard light weight.
0N/A * @see #WEIGHT
0N/A */
0N/A public static final Float WEIGHT_LIGHT =
0N/A Float.valueOf(0.75f);
0N/A
0N/A /**
0N/A * An intermediate weight between <code>WEIGHT_LIGHT</code> and
0N/A * <code>WEIGHT_STANDARD</code>.
0N/A * @see #WEIGHT
0N/A */
0N/A public static final Float WEIGHT_DEMILIGHT =
0N/A Float.valueOf(0.875f);
0N/A
0N/A /**
0N/A * The standard weight. This is the default value for <code>WEIGHT</code>.
0N/A * @see #WEIGHT
0N/A */
0N/A public static final Float WEIGHT_REGULAR =
0N/A Float.valueOf(1.0f);
0N/A
0N/A /**
0N/A * A moderately heavier weight than <code>WEIGHT_REGULAR</code>.
0N/A * @see #WEIGHT
0N/A */
0N/A public static final Float WEIGHT_SEMIBOLD =
0N/A Float.valueOf(1.25f);
0N/A
0N/A /**
0N/A * An intermediate weight between <code>WEIGHT_REGULAR</code> and
0N/A * <code>WEIGHT_BOLD</code>.
0N/A * @see #WEIGHT
0N/A */
0N/A public static final Float WEIGHT_MEDIUM =
0N/A Float.valueOf(1.5f);
0N/A
0N/A /**
0N/A * A moderately lighter weight than <code>WEIGHT_BOLD</code>.
0N/A * @see #WEIGHT
0N/A */
0N/A public static final Float WEIGHT_DEMIBOLD =
0N/A Float.valueOf(1.75f);
0N/A
0N/A /**
0N/A * The standard bold weight.
0N/A * @see #WEIGHT
0N/A */
0N/A public static final Float WEIGHT_BOLD =
0N/A Float.valueOf(2.0f);
0N/A
0N/A /**
0N/A * A moderately heavier weight than <code>WEIGHT_BOLD</code>.
0N/A * @see #WEIGHT
0N/A */
0N/A public static final Float WEIGHT_HEAVY =
0N/A Float.valueOf(2.25f);
0N/A
0N/A /**
0N/A * An extra heavy weight.
0N/A * @see #WEIGHT
0N/A */
0N/A public static final Float WEIGHT_EXTRABOLD =
0N/A Float.valueOf(2.5f);
0N/A
0N/A /**
0N/A * The heaviest predefined weight.
0N/A * @see #WEIGHT
0N/A */
0N/A public static final Float WEIGHT_ULTRABOLD =
0N/A Float.valueOf(2.75f);
0N/A
0N/A /**
0N/A * Attribute key for the width of a font. Values are instances of
0N/A * <b><code>Number</code></b>. The default value is
0N/A * <code>WIDTH_REGULAR</code>.
0N/A *
0N/A * <p>Several constant values are provided, see {@link
0N/A * #WIDTH_CONDENSED}, {@link #WIDTH_SEMI_CONDENSED}, {@link
0N/A * #WIDTH_REGULAR}, {@link #WIDTH_SEMI_EXTENDED}, {@link
0N/A * #WIDTH_EXTENDED}.
0N/A *
0N/A * <p>The value is roughly the ratio of the advance width to that
0N/A * of the regular width.
0N/A *
0N/A * <p>The system can interpolate the provided value.
0N/A */
0N/A public static final TextAttribute WIDTH =
0N/A new TextAttribute("width");
0N/A
0N/A /**
0N/A * The most condensed predefined width.
0N/A * @see #WIDTH
0N/A */
0N/A public static final Float WIDTH_CONDENSED =
0N/A Float.valueOf(0.75f);
0N/A
0N/A /**
0N/A * A moderately condensed width.
0N/A * @see #WIDTH
0N/A */
0N/A public static final Float WIDTH_SEMI_CONDENSED =
0N/A Float.valueOf(0.875f);
0N/A
0N/A /**
0N/A * The standard width. This is the default value for
0N/A * <code>WIDTH</code>.
0N/A * @see #WIDTH
0N/A */
0N/A public static final Float WIDTH_REGULAR =
0N/A Float.valueOf(1.0f);
0N/A
0N/A /**
0N/A * A moderately extended width.
0N/A * @see #WIDTH
0N/A */
0N/A public static final Float WIDTH_SEMI_EXTENDED =
0N/A Float.valueOf(1.25f);
0N/A
0N/A /**
0N/A * The most extended predefined width.
0N/A * @see #WIDTH
0N/A */
0N/A public static final Float WIDTH_EXTENDED =
0N/A Float.valueOf(1.5f);
0N/A
0N/A /**
0N/A * Attribute key for the posture of a font. Values are instances
0N/A * of <b><code>Number</code></b>. The default value is
0N/A * <code>POSTURE_REGULAR</code>.
0N/A *
0N/A * <p>Two constant values are provided, {@link #POSTURE_REGULAR}
0N/A * and {@link #POSTURE_OBLIQUE}. The value
0N/A * <code>POSTURE_OBLIQUE</code> corresponds to the style value
0N/A * <code>Font.ITALIC</code> as passed to the <code>Font</code>
0N/A * constructor.
0N/A *
0N/A * <p>The value is roughly the slope of the stems of the font,
0N/A * expressed as the run over the rise. Positive values lean right.
0N/A *
0N/A * <p>The system can interpolate the provided value.
0N/A *
0N/A * <p>This will affect the font's italic angle as returned by
0N/A * <code>Font.getItalicAngle</code>.
0N/A *
0N/A * @see java.awt.Font#getItalicAngle()
0N/A */
0N/A public static final TextAttribute POSTURE =
0N/A new TextAttribute("posture");
0N/A
0N/A /**
0N/A * The standard posture, upright. This is the default value for
0N/A * <code>POSTURE</code>.
0N/A * @see #POSTURE
0N/A */
0N/A public static final Float POSTURE_REGULAR =
0N/A Float.valueOf(0.0f);
0N/A
0N/A /**
0N/A * The standard italic posture.
0N/A * @see #POSTURE
0N/A */
0N/A public static final Float POSTURE_OBLIQUE =
0N/A Float.valueOf(0.20f);
0N/A
0N/A /**
0N/A * Attribute key for the font size. Values are instances of
0N/A * <b><code>Number</code></b>. The default value is 12pt.
0N/A *
0N/A * <p>This corresponds to the <code>size</code> parameter to the
0N/A * <code>Font</code> constructor.
0N/A *
0N/A * <p>Very large or small sizes will impact rendering performance,
0N/A * and the rendering system might not render text at these sizes.
0N/A * Negative sizes are illegal and result in the default size.
0N/A *
0N/A * <p>Note that the appearance and metrics of a 12pt font with a
0N/A * 2x transform might be different than that of a 24 point font
0N/A * with no transform.
0N/A */
0N/A public static final TextAttribute SIZE =
0N/A new TextAttribute("size");
0N/A
0N/A /**
0N/A * Attribute key for the transform of a font. Values are
0N/A * instances of <b><code>TransformAttribute</code></b>. The
0N/A * default value is <code>TransformAttribute.IDENTITY</code>.
0N/A *
0N/A * <p>The <code>TransformAttribute</code> class defines the
0N/A * constant {@link TransformAttribute#IDENTITY IDENTITY}.
0N/A *
0N/A * <p>This corresponds to the transform passed to
0N/A * <code>Font.deriveFont(AffineTransform)</code>. Since that
0N/A * transform is mutable and <code>TextAttribute</code> values must
0N/A * not be, the <code>TransformAttribute</code> wrapper class is
0N/A * used.
0N/A *
0N/A * <p>The primary intent is to support scaling and skewing, though
0N/A * other effects are possible.</p>
0N/A *
0N/A * <p>Some transforms will cause the baseline to be rotated and/or
0N/A * shifted. The text and the baseline are transformed together so
0N/A * that the text follows the new baseline. For example, with text
0N/A * on a horizontal baseline, the new baseline follows the
0N/A * direction of the unit x vector passed through the
0N/A * transform. Text metrics are measured against this new baseline.
0N/A * So, for example, with other things being equal, text rendered
0N/A * with a rotated TRANSFORM and an unrotated TRANSFORM will measure as
0N/A * having the same ascent, descent, and advance.</p>
0N/A *
0N/A * <p>In styled text, the baselines for each such run are aligned
0N/A * one after the other to potentially create a non-linear baseline
0N/A * for the entire run of text. For more information, see {@link
0N/A * TextLayout#getLayoutPath}.</p>
0N/A *
0N/A * @see TransformAttribute
0N/A * @see java.awt.geom.AffineTransform
0N/A */
0N/A public static final TextAttribute TRANSFORM =
0N/A new TextAttribute("transform");
0N/A
0N/A /**
0N/A * Attribute key for superscripting and subscripting. Values are
0N/A * instances of <b><code>Integer</code></b>. The default value is
0N/A * 0, which means that no superscript or subscript is used.
0N/A *
0N/A * <p>Two constant values are provided, see {@link
0N/A * #SUPERSCRIPT_SUPER} and {@link #SUPERSCRIPT_SUB}. These have
0N/A * the values 1 and -1 respectively. Values of
0N/A * greater magnitude define greater levels of superscript or
0N/A * subscripting, for example, 2 corresponds to super-superscript,
0N/A * 3 to super-super-superscript, and similarly for negative values
0N/A * and subscript, up to a level of 7 (or -7). Values beyond this
0N/A * range are reserved; behavior is platform-dependent.
0N/A *
0N/A * <p><code>SUPERSCRIPT</code> can
0N/A * impact the ascent and descent of a font. The ascent
0N/A * and descent can never become negative, however.
0N/A */
0N/A public static final TextAttribute SUPERSCRIPT =
0N/A new TextAttribute("superscript");
0N/A
0N/A /**
0N/A * Standard superscript.
0N/A * @see #SUPERSCRIPT
0N/A */
0N/A public static final Integer SUPERSCRIPT_SUPER =
0N/A Integer.valueOf(1);
0N/A
0N/A /**
0N/A * Standard subscript.
0N/A * @see #SUPERSCRIPT
0N/A */
0N/A public static final Integer SUPERSCRIPT_SUB =
0N/A Integer.valueOf(-1);
0N/A
0N/A /**
0N/A * Attribute key used to provide the font to use to render text.
0N/A * Values are instances of {@link java.awt.Font}. The default
0N/A * value is null, indicating that normal resolution of a
0N/A * <code>Font</code> from attributes should be performed.
0N/A *
0N/A * <p><code>TextLayout</code> and
0N/A * <code>AttributedCharacterIterator</code> work in terms of
0N/A * <code>Maps</code> of <code>TextAttributes</code>. Normally,
0N/A * all the attributes are examined and used to select and
0N/A * configure a <code>Font</code> instance. If a <code>FONT</code>
0N/A * attribute is present, though, its associated <code>Font</code>
0N/A * will be used. This provides a way for users to override the
0N/A * resolution of font attributes into a <code>Font</code>, or
0N/A * force use of a particular <code>Font</code> instance. This
0N/A * also allows users to specify subclasses of <code>Font</code> in
0N/A * cases where a <code>Font</code> can be subclassed.
0N/A *
0N/A * <p><code>FONT</code> is used for special situations where
0N/A * clients already have a <code>Font</code> instance but still
0N/A * need to use <code>Map</code>-based APIs. Typically, there will
0N/A * be no other attributes in the <code>Map</code> except the
0N/A * <code>FONT</code> attribute. With <code>Map</code>-based APIs
0N/A * the common case is to specify all attributes individually, so
0N/A * <code>FONT</code> is not needed or desireable.
0N/A *
0N/A * <p>However, if both <code>FONT</code> and other attributes are
0N/A * present in the <code>Map</code>, the rendering system will
0N/A * merge the attributes defined in the <code>Font</code> with the
0N/A * additional attributes. This merging process classifies
0N/A * <code>TextAttributes</code> into two groups. One group, the
0N/A * 'primary' group, is considered fundamental to the selection and
0N/A * metric behavior of a font. These attributes are
0N/A * <code>FAMILY</code>, <code>WEIGHT</code>, <code>WIDTH</code>,
0N/A * <code>POSTURE</code>, <code>SIZE</code>,
0N/A * <code>TRANSFORM</code>, <code>SUPERSCRIPT</code>, and
0N/A * <code>TRACKING</code>. The other group, the 'secondary' group,
0N/A * consists of all other defined attributes, with the exception of
0N/A * <code>FONT</code> itself.
0N/A *
0N/A * <p>To generate the new <code>Map</code>, first the
0N/A * <code>Font</code> is obtained from the <code>FONT</code>
0N/A * attribute, and <em>all</em> of its attributes extracted into a
0N/A * new <code>Map</code>. Then only the <em>secondary</em>
0N/A * attributes from the original <code>Map</code> are added to
0N/A * those in the new <code>Map</code>. Thus the values of primary
0N/A * attributes come solely from the <code>Font</code>, and the
0N/A * values of secondary attributes originate with the
0N/A * <code>Font</code> but can be overridden by other values in the
0N/A * <code>Map</code>.
0N/A *
0N/A * <p><em>Note:</em><code>Font's</code> <code>Map</code>-based
0N/A * constructor and <code>deriveFont</code> methods do not process
0N/A * the <code>FONT</code> attribute, as these are used to create
0N/A * new <code>Font</code> objects. Instead, {@link
0N/A * java.awt.Font#getFont(Map) Font.getFont(Map)} should be used to
0N/A * handle the <code>FONT</code> attribute.
0N/A *
0N/A * @see java.awt.Font
0N/A */
0N/A public static final TextAttribute FONT =
0N/A new TextAttribute("font");
0N/A
0N/A /**
0N/A * Attribute key for a user-defined glyph to display in lieu
0N/A * of the font's standard glyph for a character. Values are
0N/A * intances of GraphicAttribute. The default value is null,
0N/A * indicating that the standard glyphs provided by the font
0N/A * should be used.
0N/A *
0N/A * <p>This attribute is used to reserve space for a graphic or
0N/A * other component embedded in a line of text. It is required for
0N/A * correct positioning of 'inline' components within a line when
0N/A * bidirectional reordering (see {@link java.text.Bidi}) is
0N/A * performed. Each character (Unicode code point) will be
0N/A * rendered using the provided GraphicAttribute. Typically, the
0N/A * characters to which this attribute is applied should be
0N/A * <code>&#92;uFFFC</code>.
0N/A *
0N/A * <p>The GraphicAttribute determines the logical and visual
0N/A * bounds of the text; the actual Font values are ignored.
0N/A *
0N/A * @see GraphicAttribute
0N/A */
0N/A public static final TextAttribute CHAR_REPLACEMENT =
0N/A new TextAttribute("char_replacement");
0N/A
0N/A //
0N/A // Adornments added to text.
0N/A //
0N/A
0N/A /**
0N/A * Attribute key for the paint used to render the text. Values are
0N/A * instances of <b><code>Paint</code></b>. The default value is
0N/A * null, indicating that the <code>Paint</code> set on the
0N/A * <code>Graphics2D</code> at the time of rendering is used.
0N/A *
0N/A * <p>Glyphs will be rendered using this
0N/A * <code>Paint</code> regardless of the <code>Paint</code> value
0N/A * set on the <code>Graphics</code> (but see {@link #SWAP_COLORS}).
0N/A *
0N/A * @see java.awt.Paint
0N/A * @see #SWAP_COLORS
0N/A */
0N/A public static final TextAttribute FOREGROUND =
0N/A new TextAttribute("foreground");
0N/A
0N/A /**
0N/A * Attribute key for the paint used to render the background of
0N/A * the text. Values are instances of <b><code>Paint</code></b>.
0N/A * The default value is null, indicating that the background
0N/A * should not be rendered.
0N/A *
0N/A * <p>The logical bounds of the text will be filled using this
0N/A * <code>Paint</code>, and then the text will be rendered on top
0N/A * of it (but see {@link #SWAP_COLORS}).
0N/A *
0N/A * <p>The visual bounds of the text is extended to include the
0N/A * logical bounds, if necessary. The outline is not affected.
0N/A *
0N/A * @see java.awt.Paint
0N/A * @see #SWAP_COLORS
0N/A */
0N/A public static final TextAttribute BACKGROUND =
0N/A new TextAttribute("background");
0N/A
0N/A /**
0N/A * Attribute key for underline. Values are instances of
0N/A * <b><code>Integer</code></b>. The default value is -1, which
0N/A * means no underline.
0N/A *
0N/A * <p>The constant value {@link #UNDERLINE_ON} is provided.
0N/A *
0N/A * <p>The underline affects both the visual bounds and the outline
0N/A * of the text.
0N/A */
0N/A public static final TextAttribute UNDERLINE =
0N/A new TextAttribute("underline");
0N/A
0N/A /**
0N/A * Standard underline.
0N/A *
0N/A * @see #UNDERLINE
0N/A */
0N/A public static final Integer UNDERLINE_ON =
0N/A Integer.valueOf(0);
0N/A
0N/A /**
0N/A * Attribute key for strikethrough. Values are instances of
0N/A * <b><code>Boolean</code></b>. The default value is
0N/A * <code>false</code>, which means no strikethrough.
0N/A *
0N/A * <p>The constant value {@link #STRIKETHROUGH_ON} is provided.
0N/A *
0N/A * <p>The strikethrough affects both the visual bounds and the
0N/A * outline of the text.
0N/A */
0N/A public static final TextAttribute STRIKETHROUGH =
0N/A new TextAttribute("strikethrough");
0N/A
0N/A /**
0N/A * A single strikethrough.
0N/A *
0N/A * @see #STRIKETHROUGH
0N/A */
0N/A public static final Boolean STRIKETHROUGH_ON =
0N/A Boolean.TRUE;
0N/A
0N/A //
0N/A // Attributes use to control layout of text on a line.
0N/A //
0N/A
0N/A /**
0N/A * Attribute key for the run direction of the line. Values are
0N/A * instances of <b><code>Boolean</code></b>. The default value is
0N/A * null, which indicates that the standard Bidi algorithm for
0N/A * determining run direction should be used with the value {@link
0N/A * java.text.Bidi#DIRECTION_DEFAULT_LEFT_TO_RIGHT}.
0N/A *
0N/A * <p>The constants {@link #RUN_DIRECTION_RTL} and {@link
0N/A * #RUN_DIRECTION_LTR} are provided.
0N/A *
0N/A * <p>This determines the value passed to the {@link
0N/A * java.text.Bidi} constructor to select the primary direction of
0N/A * the text in the paragraph.
0N/A *
0N/A * <p><em>Note:</em> This attribute should have the same value for
0N/A * all the text in a paragraph, otherwise the behavior is
0N/A * undetermined.
0N/A *
0N/A * @see java.text.Bidi
0N/A */
0N/A public static final TextAttribute RUN_DIRECTION =
0N/A new TextAttribute("run_direction");
0N/A
0N/A /**
0N/A * Left-to-right run direction.
0N/A * @see #RUN_DIRECTION
0N/A */
0N/A public static final Boolean RUN_DIRECTION_LTR =
0N/A Boolean.FALSE;
0N/A
0N/A /**
0N/A * Right-to-left run direction.
0N/A * @see #RUN_DIRECTION
0N/A */
0N/A public static final Boolean RUN_DIRECTION_RTL =
0N/A Boolean.TRUE;
0N/A
0N/A /**
0N/A * Attribute key for the embedding level of the text. Values are
0N/A * instances of <b><code>Integer</code></b>. The default value is
0N/A * <code>null</code>, indicating that the the Bidirectional
0N/A * algorithm should run without explicit embeddings.
0N/A *
0N/A * <p>Positive values 1 through 61 are <em>embedding</em> levels,
0N/A * negative values -1 through -61 are <em>override</em> levels.
0N/A * The value 0 means that the base line direction is used. These
0N/A * levels are passed in the embedding levels array to the {@link
0N/A * java.text.Bidi} constructor.
0N/A *
0N/A * <p><em>Note:</em> When this attribute is present anywhere in
0N/A * a paragraph, then any Unicode bidi control characters (RLO,
0N/A * LRO, RLE, LRE, and PDF) in the paragraph are
0N/A * disregarded, and runs of text where this attribute is not
0N/A * present are treated as though it were present and had the value
0N/A * 0.
0N/A *
0N/A * @see java.text.Bidi
0N/A */
0N/A public static final TextAttribute BIDI_EMBEDDING =
0N/A new TextAttribute("bidi_embedding");
0N/A
0N/A /**
0N/A * Attribute key for the justification of a paragraph. Values are
0N/A * instances of <b><code>Number</code></b>. The default value is
0N/A * 1, indicating that justification should use the full width
0N/A * provided. Values are pinned to the range [0..1].
0N/A *
0N/A * <p>The constants {@link #JUSTIFICATION_FULL} and {@link
0N/A * #JUSTIFICATION_NONE} are provided.
0N/A *
0N/A * <p>Specifies the fraction of the extra space to use when
0N/A * justification is requested on a <code>TextLayout</code>. For
0N/A * example, if the line is 50 points wide and it is requested to
0N/A * justify to 70 points, a value of 0.75 will pad to use
0N/A * three-quarters of the remaining space, or 15 points, so that
0N/A * the resulting line will be 65 points in length.
0N/A *
0N/A * <p><em>Note:</em> This should have the same value for all the
0N/A * text in a paragraph, otherwise the behavior is undetermined.
0N/A *
0N/A * @see TextLayout#getJustifiedLayout
0N/A */
0N/A public static final TextAttribute JUSTIFICATION =
0N/A new TextAttribute("justification");
0N/A
0N/A /**
0N/A * Justify the line to the full requested width. This is the
0N/A * default value for <code>JUSTIFICATION</code>.
0N/A * @see #JUSTIFICATION
0N/A */
0N/A public static final Float JUSTIFICATION_FULL =
0N/A Float.valueOf(1.0f);
0N/A
0N/A /**
0N/A * Do not allow the line to be justified.
0N/A * @see #JUSTIFICATION
0N/A */
0N/A public static final Float JUSTIFICATION_NONE =
0N/A Float.valueOf(0.0f);
0N/A
0N/A //
0N/A // For use by input method.
0N/A //
0N/A
0N/A /**
0N/A * Attribute key for input method highlight styles.
0N/A *
0N/A * <p>Values are instances of {@link
0N/A * java.awt.im.InputMethodHighlight} or {@link
0N/A * java.text.Annotation}. The default value is <code>null</code>,
0N/A * which means that input method styles should not be applied
0N/A * before rendering.
0N/A *
0N/A * <p>If adjacent runs of text with the same
0N/A * <code>InputMethodHighlight</code> need to be rendered
0N/A * separately, the <code>InputMethodHighlights</code> should be
0N/A * wrapped in <code>Annotation</code> instances.
0N/A *
0N/A * <p>Input method highlights are used while text is being
0N/A * composed by an input method. Text editing components should
0N/A * retain them even if they generally only deal with unstyled
0N/A * text, and make them available to the drawing routines.
0N/A *
0N/A * @see java.awt.Font
0N/A * @see java.awt.im.InputMethodHighlight
0N/A * @see java.text.Annotation
0N/A */
0N/A public static final TextAttribute INPUT_METHOD_HIGHLIGHT =
0N/A new TextAttribute("input method highlight");
0N/A
0N/A /**
0N/A * Attribute key for input method underlines. Values
0N/A * are instances of <b><code>Integer</code></b>. The default
0N/A * value is <code>-1</code>, which means no underline.
0N/A *
0N/A * <p>Several constant values are provided, see {@link
0N/A * #UNDERLINE_LOW_ONE_PIXEL}, {@link #UNDERLINE_LOW_TWO_PIXEL},
0N/A * {@link #UNDERLINE_LOW_DOTTED}, {@link #UNDERLINE_LOW_GRAY}, and
0N/A * {@link #UNDERLINE_LOW_DASHED}.
0N/A *
0N/A * <p>This may be used in conjunction with {@link #UNDERLINE} if
0N/A * desired. The primary purpose is for use by input methods.
0N/A * Other use of these underlines for simple ornamentation might
0N/A * confuse users.
0N/A *
0N/A * <p>The input method underline affects both the visual bounds and
0N/A * the outline of the text.
0N/A *
0N/A * @since 1.3
0N/A */
0N/A public static final TextAttribute INPUT_METHOD_UNDERLINE =
0N/A new TextAttribute("input method underline");
0N/A
0N/A /**
0N/A * Single pixel solid low underline.
0N/A * @see #INPUT_METHOD_UNDERLINE
0N/A * @since 1.3
0N/A */
0N/A public static final Integer UNDERLINE_LOW_ONE_PIXEL =
0N/A Integer.valueOf(1);
0N/A
0N/A /**
0N/A * Double pixel solid low underline.
0N/A * @see #INPUT_METHOD_UNDERLINE
0N/A * @since 1.3
0N/A */
0N/A public static final Integer UNDERLINE_LOW_TWO_PIXEL =
0N/A Integer.valueOf(2);
0N/A
0N/A /**
0N/A * Single pixel dotted low underline.
0N/A * @see #INPUT_METHOD_UNDERLINE
0N/A * @since 1.3
0N/A */
0N/A public static final Integer UNDERLINE_LOW_DOTTED =
0N/A Integer.valueOf(3);
0N/A
0N/A /**
0N/A * Double pixel gray low underline.
0N/A * @see #INPUT_METHOD_UNDERLINE
0N/A * @since 1.3
0N/A */
0N/A public static final Integer UNDERLINE_LOW_GRAY =
0N/A Integer.valueOf(4);
0N/A
0N/A /**
0N/A * Single pixel dashed low underline.
0N/A * @see #INPUT_METHOD_UNDERLINE
0N/A * @since 1.3
0N/A */
0N/A public static final Integer UNDERLINE_LOW_DASHED =
0N/A Integer.valueOf(5);
0N/A
0N/A /**
0N/A * Attribute key for swapping foreground and background
0N/A * <code>Paints</code>. Values are instances of
0N/A * <b><code>Boolean</code></b>. The default value is
0N/A * <code>false</code>, which means do not swap colors.
0N/A *
0N/A * <p>The constant value {@link #SWAP_COLORS_ON} is defined.
0N/A *
0N/A * <p>If the {@link #FOREGROUND} attribute is set, its
0N/A * <code>Paint</code> will be used as the background, otherwise
0N/A * the <code>Paint</code> currently on the <code>Graphics</code>
0N/A * will be used. If the {@link #BACKGROUND} attribute is set, its
0N/A * <code>Paint</code> will be used as the foreground, otherwise
0N/A * the system will find a contrasting color to the
0N/A * (resolved) background so that the text will be visible.
0N/A *
0N/A * @see #FOREGROUND
0N/A * @see #BACKGROUND
0N/A */
0N/A public static final TextAttribute SWAP_COLORS =
0N/A new TextAttribute("swap_colors");
0N/A
0N/A /**
0N/A * Swap foreground and background.
0N/A * @see #SWAP_COLORS
0N/A * @since 1.3
0N/A */
0N/A public static final Boolean SWAP_COLORS_ON =
0N/A Boolean.TRUE;
0N/A
0N/A /**
0N/A * Attribute key for converting ASCII decimal digits to other
0N/A * decimal ranges. Values are instances of {@link NumericShaper}.
0N/A * The default is <code>null</code>, which means do not perform
0N/A * numeric shaping.
0N/A *
0N/A * <p>When a numeric shaper is defined, the text is first
0N/A * processed by the shaper before any other analysis of the text
0N/A * is performed.
0N/A *
0N/A * <p><em>Note:</em> This should have the same value for all the
0N/A * text in the paragraph, otherwise the behavior is undetermined.
0N/A *
0N/A * @see NumericShaper
0N/A * @since 1.4
0N/A */
0N/A public static final TextAttribute NUMERIC_SHAPING =
0N/A new TextAttribute("numeric_shaping");
0N/A
0N/A /**
0N/A * Attribute key to request kerning. Values are instances of
0N/A * <b><code>Integer</code></b>. The default value is
0N/A * <code>0</code>, which does not request kerning.
0N/A *
0N/A * <p>The constant value {@link #KERNING_ON} is provided.
0N/A *
0N/A * <p>The default advances of single characters are not
0N/A * appropriate for some character sequences, for example "To" or
0N/A * "AWAY". Without kerning the adjacent characters appear to be
0N/A * separated by too much space. Kerning causes selected sequences
0N/A * of characters to be spaced differently for a more pleasing
0N/A * visual appearance.
0N/A *
0N/A * @since 1.6
0N/A */
0N/A public static final TextAttribute KERNING =
0N/A new TextAttribute("kerning");
0N/A
0N/A /**
0N/A * Request standard kerning.
0N/A * @see #KERNING
0N/A * @since 1.6
0N/A */
0N/A public static final Integer KERNING_ON =
0N/A Integer.valueOf(1);
0N/A
0N/A
0N/A /**
0N/A * Attribute key for enabling optional ligatures. Values are
0N/A * instances of <b><code>Integer</code></b>. The default value is
0N/A * <code>0</code>, which means do not use optional ligatures.
0N/A *
0N/A * <p>The constant value {@link #LIGATURES_ON} is defined.
0N/A *
0N/A * <p>Ligatures required by the writing system are always enabled.
0N/A *
0N/A * @since 1.6
0N/A */
0N/A public static final TextAttribute LIGATURES =
0N/A new TextAttribute("ligatures");
0N/A
0N/A /**
0N/A * Request standard optional ligatures.
0N/A * @see #LIGATURES
0N/A * @since 1.6
0N/A */
0N/A public static final Integer LIGATURES_ON =
0N/A Integer.valueOf(1);
0N/A
0N/A /**
0N/A * Attribute key to control tracking. Values are instances of
0N/A * <b><code>Number</code></b>. The default value is
0N/A * <code>0</code>, which means no additional tracking.
0N/A *
0N/A * <p>The constant values {@link #TRACKING_TIGHT} and {@link
0N/A * #TRACKING_LOOSE} are provided.
0N/A *
0N/A * <p>The tracking value is multiplied by the font point size and
0N/A * passed through the font transform to determine an additional
0N/A * amount to add to the advance of each glyph cluster. Positive
0N/A * tracking values will inhibit formation of optional ligatures.
0N/A * Tracking values are typically between <code>-0.1</code> and
0N/A * <code>0.3</code>; values outside this range are generally not
0N/A * desireable.
0N/A *
0N/A * @since 1.6
0N/A */
0N/A public static final TextAttribute TRACKING =
0N/A new TextAttribute("tracking");
0N/A
0N/A /**
0N/A * Perform tight tracking.
0N/A * @see #TRACKING
0N/A * @since 1.6
0N/A */
0N/A public static final Float TRACKING_TIGHT =
0N/A Float.valueOf(-.04f);
0N/A
0N/A /**
0N/A * Perform loose tracking.
0N/A * @see #TRACKING
0N/A * @since 1.6
0N/A */
0N/A public static final Float TRACKING_LOOSE =
0N/A Float.valueOf(.04f);
0N/A}