1 /* Font.java -- Font object
2 Copyright (C) 1999, 2002 Free Software Foundation, Inc.
4 This file is part of GNU Classpath.
6 GNU Classpath is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 GNU Classpath is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Classpath; see the file COPYING. If not, write to the
18 Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
21 Linking this library statically or dynamically with other modules is
22 making a combined work based on this library. Thus, the terms and
23 conditions of the GNU General Public License cover the whole
26 As a special exception, the copyright holders of this library give you
27 permission to link this library with independent modules to produce an
28 executable, regardless of the license terms of these independent
29 modules, and to copy and distribute the resulting executable under
30 terms of your choice, provided that you also meet, for each linked
31 independent module, the terms and conditions of the license of that
32 module. An independent module is a module which is not derived from
33 or based on this library. If you modify this library, you may extend
34 this exception to your version of the library, but you are not
35 obligated to do so. If you do not wish to do so, delete this
36 exception statement from your version. */
41 import java
.awt
.font
.FontRenderContext
;
42 import java
.awt
.font
.GlyphVector
;
43 import java
.awt
.font
.LineMetrics
;
44 import java
.awt
.font
.TextAttribute
;
45 import java
.awt
.geom
.AffineTransform
;
46 import java
.awt
.geom
.Rectangle2D
;
47 import java
.awt
.peer
.FontPeer
;
48 import java
.io
.InputStream
;
49 import java
.io
.IOException
;
50 import java
.io
.Serializable
;
51 import java
.util
.Locale
;
53 import java
.util
.StringTokenizer
;
54 import java
.text
.CharacterIterator
;
55 import java
.text
.AttributedCharacterIterator
;
58 * This class represents a windowing system font.
60 * @author Aaron M. Renn (arenn@urbanophile.com)
61 * @author Warren Levy <warrenl@cygnus.com>
63 public class Font
implements Serializable
71 * Constant indicating a "plain" font.
73 public static final int PLAIN
= 0;
76 * Constant indicating a "bold" font.
78 public static final int BOLD
= 1;
81 * Constant indicating an "italic" font.
83 public static final int ITALIC
= 2;
86 * Constant indicating the baseline mode characteristic of Roman.
88 public static final int ROMAN_BASELINE
= 0;
91 * Constant indicating the baseline mode characteristic of Chinese.
93 public static final int CENTER_BASELINE
= 1;
96 * Constant indicating the baseline mode characteristic of Devanigri.
98 public static final int HANGING_BASELINE
= 2;
102 * Indicates to <code>createFont</code> that the supplied font data
103 * is in TrueType format.
105 * <p><em>Specification Note:</em> The Sun JavaDoc for J2SE 1.4 does
106 * not indicate whether this value also subsumes OpenType. OpenType
107 * is essentially the same format as TrueType, but allows to define
108 * glyph shapes in the same way as PostScript, using cubic bezier
113 public static final int TRUETYPE_FONT
= 0;
117 * A flag for <code>layoutGlyphVector</code>, indicating that the
118 * orientation of a text run is from left to right.
122 public static final int LAYOUT_LEFT_TO_RIGHT
= 0;
126 * A flag for <code>layoutGlyphVector</code>, indicating that the
127 * orientation of a text run is from right to left.
131 public static final int LAYOUT_RIGHT_TO_LEFT
= 1;
135 * A flag for <code>layoutGlyphVector</code>, indicating that the
136 * text does not contain valid characters before the
137 * <code>start</code> position. If this flag is set,
138 * <code>layoutGlyphVector</code> does not examine the text before
139 * <code>start</code>, even if this would be necessary to select the
140 * correct glyphs (e.g., for Arabic text).
144 public static final int LAYOUT_NO_START_CONTEXT
= 2;
148 * A flag for <code>layoutGlyphVector</code>, indicating that the
149 * text does not contain valid characters after the
150 * <code>limit</code> position. If this flag is set,
151 * <code>layoutGlyphVector</code> does not examine the text after
152 * <code>limit</code>, even if this would be necessary to select the
153 * correct glyphs (e.g., for Arabic text).
157 public static final int LAYOUT_NO_LIMIT_CONTEXT
= 4;
160 // Serialization constant
161 private static final long serialVersionUID
= -4206021311591459213L;
163 /*************************************************************************/
170 * The name of this font
172 protected String name
;
175 * The font style, which is a combination (by summing, not OR-ing) of
176 * the font style constants in this class.
181 * The font point size.
185 protected float pointSize
;
187 // The native peer for this font
188 private FontPeer peer
;
190 /*************************************************************************/
197 * Creates a <code>Font</code> object from the specified string, which
198 * is in one of the following formats:
201 * <li>fontname-style-pointsize
203 * <li>fontname-pointsize
207 * The style should be one of BOLD, ITALIC, or BOLDITALIC. The default
208 * style if none is specified is PLAIN. The default size if none
209 * is specified is 12.
212 decode(String fontspec
)
218 StringTokenizer st
= new StringTokenizer(fontspec
, "-");
219 while (st
.hasMoreTokens())
221 String token
= st
.nextToken();
228 if (token
.toUpperCase().equals("BOLD"))
233 if (token
.toUpperCase().equals("ITALIC"))
238 if (token
.toUpperCase().equals("BOLDITALIC"))
240 style
= BOLD
+ ITALIC
;
247 tokenval
= Integer
.parseInt(token
);
249 catch(NumberFormatException e
) { ; }
255 return(new Font(name
, style
, size
));
258 /*************************************************************************/
261 * Returns a <code>Font</code> object from the passed property name.
263 * @param propname The name of the system property.
264 * @param default Value to use if the property is not found.
266 * @return The requested font, or <code>default</code> if the property
267 * not exist or is malformed.
270 getFont(String propname
, Font defval
)
272 String propval
= System
.getProperty(propname
);
274 return(decode(propval
));
279 /*************************************************************************/
282 * Returns a <code>Font</code> object from the passed property name.
284 * @param propname The name of the system property.
286 * @return The requested font, or <code>null</code> if the property
287 * not exist or is malformed.
290 getFont(String propname
)
292 return(getFont(propname
, null));
295 /*************************************************************************/
302 * Initializes a new instance of <code>Font</code> with the specified
305 * @param name The name of the font.
306 * @param style The font style.
307 * @param size The font point size.
310 Font(String name
, int style
, int size
)
315 this.pointSize
= size
;
321 throw new UnsupportedOperationException();
324 /*************************************************************************/
331 * Returns the logical name of the font. A logical name describes a very
332 * general typographic style (such as Sans Serif). It is less specific
333 * than both a font family name (such as Helvetica) and a font face name
334 * (such as Helvetica Bold).
336 * @return The logical name of the font.
347 /*************************************************************************/
350 * Returns the style of the font.
352 * @return The font style.
366 /*************************************************************************/
369 * Tests whether or not this is a plain font. This will be true if
370 * and only if neither the bold nor the italics style is set.
372 * @return <code>true</code> if this is a plain font, <code>false</code>
384 /*************************************************************************/
387 * Tests whether or not this font is bold.
389 * @return <code>true</code> if this font is bold, <code>false</code>
395 if ((style
== BOLD
) || (style
== (BOLD
+ITALIC
)))
401 /*************************************************************************/
404 * Tests whether or not this font is italic.
406 * @return <code>true</code> if this font is italic, <code>false</code>
412 if ((style
== ITALIC
) || (style
== (BOLD
+ITALIC
)))
418 /*************************************************************************/
421 * Returns the family name of this font. A family name describes a
422 * typographic style (such as Helvetica or Palatino). It is more specific
423 * than a logical font name (such as Sans Serif) but less specific than a
424 * font face name (such as Helvetica Bold).
426 * @return A string containing the font family name.
432 * @see GraphicsEnvironment.getAvailableFontFamilyNames()
437 // FIXME: How do I implement this?
442 * Returns integer code representing the sum of style flags of this font, a
443 * combination of either {@link PLAIN}, {@link BOLD}, or {@link ITALIC}.
445 * @return code representing the style of this font.
458 * Checks if specified character maps to a glyph in this font.
460 * @param c The character to check.
462 * @return Whether the character has a corresponding glyph in this font.
469 throw new UnsupportedOperationException ();
473 * Checks how much of a given string can be mapped to glyphs in
476 * @param s The string to check.
478 * @return The index of the first character in <code>s</code> which cannot
479 * be converted to a glyph by this font, or <code>-1</code> if all
480 * characters can be mapped to glyphs.
485 canDisplayUpTo(String s
)
487 throw new UnsupportedOperationException ();
491 * Checks how much of a given sequence of text can be mapped to glyphs in
494 * @param text Array containing the text to check.
495 * @param start Position of first character to check in <code>text</code>.
496 * @param limit Position of last character to check in <code>text</code>.
498 * @return The index of the first character in the indicated range which
499 * cannot be converted to a glyph by this font, or <code>-1</code> if all
500 * characters can be mapped to glyphs.
504 * @throws IndexOutOfBoundsException if the range [start, limit] is
505 * invalid in <code>text</code>.
508 canDisplayUpTo(char[] text
, int start
, int limit
)
510 throw new UnsupportedOperationException ();
514 * Checks how much of a given sequence of text can be mapped to glyphs in
517 * @param i Iterator over the text to check.
518 * @param start Position of first character to check in <code>i</code>.
519 * @param limit Position of last character to check in <code>i</code>.
521 * @return The index of the first character in the indicated range which
522 * cannot be converted to a glyph by this font, or <code>-1</code> if all
523 * characters can be mapped to glyphs.
527 * @throws IndexOutOfBoundsException if the range [start, limit] is
528 * invalid in <code>i</code>.
531 canDisplayUpTo(CharacterIterator i
, int start
, int limit
)
533 throw new UnsupportedOperationException ();
537 * Creates a new font with point size 1 and {@link PLAIN} style,
538 * reading font data from the provided input stream. The resulting font
539 * can have further fonts derived from it using its
540 * <code>deriveFont</code> method.
542 * @param fontFormat Integer code indicating the format the font data is
543 * in.Currently this can only be {@link TRUETYPE_FONT}.
544 * @param is {@link InputStream} from which font data will be read. This
545 * stream is not closed after font data is extracted.
547 * @return A new {@link Font} of the format indicated.
549 * @throws IllegalArgumentException if <code>fontType</code> is not
551 * @throws FontFormatException if data in InputStream is not of format
553 * @throws IOException if insufficient data is present on InputStream.
558 createFont(int fontFormat
, InputStream is
)
559 throws FontFormatException
, IOException
561 throw new UnsupportedOperationException ();
565 * Maps characters to glyphs in a one-to-one relationship, returning a new
566 * {@link GlyphVector} with a mapped glyph for each input character. This
567 * sort of mapping is often sufficient for some scripts such as Roman, but
568 * is inappropriate for scripts with special shaping or contextual layout
569 * requirements such as Arabic, Indic, Hebrew or Thai.
571 * @param ctx The rendering context used for precise glyph placement.
572 * @param str The string to convert to Glyphs.
574 * @return A new {@link GlyphVector} containing glyphs mapped from str,
575 * through the font's cmap table.
577 * @see layoutGlyphVector()
580 createGlyphVector(FontRenderContext ctx
, String str
)
582 throw new UnsupportedOperationException ();
586 * Maps characters to glyphs in a one-to-one relationship, returning a new
587 * {@link GlyphVector} with a mapped glyph for each input character. This
588 * sort of mapping is often sufficient for some scripts such as Roman, but
589 * is inappropriate for scripts with special shaping or contextual layout
590 * requirements such as Arabic, Indic, Hebrew or Thai.
592 * @param ctx The rendering context used for precise glyph placement.
593 * @param i Iterator over the text to convert to glyphs.
595 * @return A new {@link GlyphVector} containing glyphs mapped from str,
596 * through the font's cmap table.
598 * @see layoutGlyphVector()
601 createGlyphVector(FontRenderContext ctx
, CharacterIterator i
)
603 throw new UnsupportedOperationException ();
607 * Maps characters to glyphs in a one-to-one relationship, returning a new
608 * {@link GlyphVector} with a mapped glyph for each input character. This
609 * sort of mapping is often sufficient for some scripts such as Roman, but
610 * is inappropriate for scripts with special shaping or contextual layout
611 * requirements such as Arabic, Indic, Hebrew or Thai.
613 * @param ctx The rendering context used for precise glyph placement.
614 * @param chars Array of characters to convert to glyphs.
616 * @return A new {@link GlyphVector} containing glyphs mapped from str,
617 * through the font's cmap table.
619 * @see layoutGlyphVector()
622 createGlyphVector(FontRenderContext ctx
, char[] chars
)
624 throw new UnsupportedOperationException ();
628 * Extracts a sequence of glyphs from a font, returning a new {@link
629 * GlyphVector} with a mapped glyph for each input glyph code.
631 * @param ctx The rendering context used for precise glyph placement.
632 * @param chars Array of characters to convert to glyphs.
634 * @return A new {@link GlyphVector} containing glyphs mapped from str,
635 * through the font's cmap table.
637 * @see layoutGlyphVector()
639 * @specnote This method is documented to perform character-to-glyph
640 * conversions, in the Sun documentation, but its second parameter name is
641 * "glyphCodes" and it is not clear to me why it would exist if its
642 * purpose was to transport character codes inside integers. I assume it
643 * is mis-documented in the Sun documentation.
646 createGlyphVector(FontRenderContext ctx
, int[] glyphCodes
)
648 throw new UnsupportedOperationException ();
652 * Produces a new {@link Font} based on the current font, adjusted to a
655 * @param size The size of the newly created font.
657 * @return A clone of the current font, with the specified size.
662 deriveFont(float size
)
664 throw new UnsupportedOperationException ();
668 * Produces a new {@link Font} based on the current font, adjusted to a
671 * @param style The style of the newly created font.
673 * @return A clone of the current font, with the specified style.
678 deriveFont(int style
)
680 throw new UnsupportedOperationException ();
684 * Produces a new {@link Font} based on the current font, adjusted to a
685 * new style and subjected to a new affine transformation.
687 * @param style The style of the newly created font.
688 * @param a The transformation to apply.
690 * @return A clone of the current font, with the specified style and
693 * @throws IllegalArgumentException If transformation is
699 deriveFont(int style
, AffineTransform a
)
701 throw new UnsupportedOperationException ();
705 * Produces a new {@link Font} based on the current font, adjusted to a
706 * new set of attributes.
708 * @param attributes Attributes of the newly created font.
710 * @return A clone of the current font, with the specified attributes.
715 deriveFont(Map attributes
)
717 throw new UnsupportedOperationException ();
721 * Returns a map of chracter attributes which this font currently has set.
723 * @return A map of chracter attributes which this font currently has set.
725 * @see getAvailableAttributes()
726 * @see java.text.AttributedCharacterIterator.Attribute
727 * @see java.awt.font.TextAttribute
732 throw new UnsupportedOperationException ();
736 * Returns an array of chracter attribute keys which this font understands.
738 * @return An array of chracter attribute keys which this font understands.
740 * @see getAttributes()
741 * @see java.text.AttributedCharacterIterator.Attribute
742 * @see java.awt.font.TextAttribute
744 public AttributedCharacterIterator
.Attribute
[]
745 getAvailableAttributes()
747 throw new UnsupportedOperationException ();
751 * Returns a baseline code (one of {@link ROMAN_BASELINE}, {@link
752 * CENTER_BASELINE} or {@link HANGING_BASELINE}) indicating which baseline
753 * this font will measure baseline offsets for, when presenting glyph
754 * metrics for a given character.
756 * Baseline offsets describe the position of a glyph relative to an
757 * invisible line drawn under, through the center of, or over a line of
758 * rendered text, respectively. Different scripts use different baseline
759 * modes, so clients should not assume all baseline offsets in a glyph
760 * vector are from a common baseline.
762 * @param c The character code to select a baseline mode for.
764 * @return The baseline mode which would be used in a glyph associated
765 * with the provided character.
769 * @see LineMetrics.getBaselineOffsets()
772 getBaselineFor(char c
)
774 throw new UnsupportedOperationException ();
778 * Returns the family name of this font. A family name describes a
779 * typographic style (such as Helvetica or Palatino). It is more specific
780 * than a logical font name (such as Sans Serif) but less specific than a
781 * font face name (such as Helvetica Bold).
783 * @param lc The locale in which to describe the name of the font family.
785 * @return A string containing the font family name, localized for the
792 * @see GraphicsEnvironment.getAvailableFontFamilyNames()
798 throw new UnsupportedOperationException ();
802 * Returns a font appropriate for the given attribute set.
804 * @param attributes The attributes required for the new font.
806 * @return A new Font with the given attributes.
813 getFont(Map attributes
)
815 throw new UnsupportedOperationException ();
819 * Returns the font face name of the font. A font face name describes a
820 * specific variant of a font family (such as Helvetica Bold). It is more
821 * specific than both a font family name (such as Helvetica) and a logical
822 * font name (such as Sans Serif).
824 * @return The font face name of the font.
834 throw new UnsupportedOperationException ();
838 * Returns the font face name of the font. A font face name describes a
839 * specific variant of a font family (such as Helvetica Bold). It is more
840 * specific than both a font family name (such as Helvetica) and a logical
841 * font name (such as Sans Serif).
843 * @param lc The locale in which to describe the name of the font face.
845 * @return A string containing the font face name, localized for the
854 getFontName(Locale lc
)
856 throw new UnsupportedOperationException ();
860 * Returns the italic angle of this font, a measurement of its slant when
861 * style is {@link ITALIC}. The precise meaning is the inverse slope of a
862 * caret line which "best measures" the font's italic posture.
864 * @return The italic angle.
866 * @see TextAttribute.POSTURE
871 throw new UnsupportedOperationException ();
875 * Returns a {@link LineMetrics} object constructed with the specified
876 * text and {@link FontRenderContext}.
878 * @param text The string to calculate metrics from.
879 * @param begin Index of first character in <code>text</code> to measure.
880 * @param limit Index of last character in <code>text</code> to measure.
881 * @param rc Context for calculating precise glyph placement and hints.
883 * @return A new {@link LineMetrics} object.
885 * @throws IndexOutOfBoundsException if the range [begin, limit] is
886 * invalid in <code>text</code>.
889 getLineMetrics(String text
, int begin
, int limit
, FontRenderContext rc
)
891 throw new UnsupportedOperationException ();
895 * Returns a {@link LineMetrics} object constructed with the specified
896 * text and {@link FontRenderContext}.
898 * @param chars The string to calculate metrics from.
899 * @param begin Index of first character in <code>text</code> to measure.
900 * @param limit Index of last character in <code>text</code> to measure.
901 * @param rc Context for calculating precise glyph placement and hints.
903 * @return A new {@link LineMetrics} object.
905 * @throws IndexOutOfBoundsException if the range [begin, limit] is
906 * invalid in <code>chars</code>.
909 getLineMetrics(char[] chars
, int begin
, int limit
, FontRenderContext rc
)
911 throw new UnsupportedOperationException ();
915 * Returns a {@link LineMetrics} object constructed with the specified
916 * text and {@link FontRenderContext}.
918 * @param ci The string to calculate metrics from.
919 * @param begin Index of first character in <code>text</code> to measure.
920 * @param limit Index of last character in <code>text</code> to measure.
921 * @param rc Context for calculating precise glyph placement and hints.
923 * @return A new {@link LineMetrics} object.
925 * @throws IndexOutOfBoundsException if the range [begin, limit] is
926 * invalid in <code>ci</code>.
929 getLineMetrics(CharacterIterator ci
, int begin
, int limit
, FontRenderContext rc
)
931 throw new UnsupportedOperationException ();
935 * Returns the maximal bounding box of all the bounding boxes in this
936 * font, when the font's bounding boxes are evaluated in a given {@link
939 * @param rc Context in which to evaluate bounding boxes.
941 * @return The maximal bounding box.
944 getMaxCharBounds(FontRenderContext rc
)
946 throw new UnsupportedOperationException ();
950 * Returns the glyph code this font uses to represent missing glyphs. This
951 * code will be present in glyph vectors when the font was unable to
952 * locate a glyph to represent a particular character code.
954 * @return The missing glyph code.
959 getMissingGlyphCode()
961 throw new UnsupportedOperationException ();
965 * Returns the overall number of glyphs in this font. This number is one
966 * more than the greatest glyph code used in any glyph vectors this font
967 * produces. In other words, glyph codes are taken from the range
968 * <code>[ 0, getNumGlyphs() - 1 ]</code>.
970 * @return The number of glyphs in this font.
977 throw new UnsupportedOperationException ();
981 * Returns the PostScript Name of this font.
983 * @return The PostScript Name of this font.
994 throw new UnsupportedOperationException ();
998 * Returns the logical bounds of the specified string when rendered with this
999 * font in the specified {@link FontRenderContext}. This box will include the
1000 * glyph origin, ascent, advance, height, and leading, but may not include all
1001 * diacritics or accents. To get the complete visual bounding box of all the
1002 * glyphs in a run of text, use the {@link TextLayout#getBounds} method of
1003 * {@link TextLayout}.
1005 * @param str The string to measure.
1006 * @param frc The context in which to make the precise glyph measurements.
1008 * @return A bounding box covering the logical bounds of the specified text.
1010 * @see createGlyphVector()
1013 getStringBounds(String str
, FontRenderContext frc
)
1015 throw new UnsupportedOperationException ();
1019 * Returns the logical bounds of the specified string when rendered with this
1020 * font in the specified {@link FontRenderContext}. This box will include the
1021 * glyph origin, ascent, advance, height, and leading, but may not include all
1022 * diacritics or accents. To get the complete visual bounding box of all the
1023 * glyphs in a run of text, use the {@link TextLayout#getBounds} method of
1024 * {@link TextLayout}.
1026 * @param str The string to measure.
1027 * @param begin Index of the first character in <code>str</code> to measure.
1028 * @param limit Index of the last character in <code>str</code> to measure.
1029 * @param frc The context in which to make the precise glyph measurements.
1031 * @return A bounding box covering the logical bounds of the specified text.
1033 * @throws IndexOutOfBoundsException if the range [begin, limit] is
1034 * invalid in <code>str</code>.
1038 * @see createGlyphVector()
1041 getStringBounds(String str
, int begin
, int limit
, FontRenderContext frc
)
1043 throw new UnsupportedOperationException ();
1047 * Returns the logical bounds of the specified string when rendered with this
1048 * font in the specified {@link FontRenderContext}. This box will include the
1049 * glyph origin, ascent, advance, height, and leading, but may not include all
1050 * diacritics or accents. To get the complete visual bounding box of all the
1051 * glyphs in a run of text, use the {@link TextLayout#getBounds} method of
1052 * {@link TextLayout}.
1054 * @param ci The text to measure.
1055 * @param begin Index of the first character in <code>ci</code> to measure.
1056 * @param limit Index of the last character in <code>ci</code> to measure.
1057 * @param frc The context in which to make the precise glyph measurements.
1059 * @return A bounding box covering the logical bounds of the specified text.
1061 * @throws IndexOutOfBoundsException if the range [begin, limit] is
1062 * invalid in <code>ci</code>.
1066 * @see createGlyphVector()
1069 getStringBounds(CharacterIterator ci
, int begin
, int limit
, FontRenderContext frc
)
1071 throw new UnsupportedOperationException ();
1075 * Returns the logical bounds of the specified string when rendered with this
1076 * font in the specified {@link FontRenderContext}. This box will include the
1077 * glyph origin, ascent, advance, height, and leading, but may not include all
1078 * diacritics or accents. To get the complete visual bounding box of all the
1079 * glyphs in a run of text, use the {@link TextLayout#getBounds} method of
1080 * {@link TextLayout}.
1082 * @param chars The text to measure.
1083 * @param begin Index of the first character in <code>ci</code> to measure.
1084 * @param limit Index of the last character in <code>ci</code> to measure.
1085 * @param frc The context in which to make the precise glyph measurements.
1087 * @return A bounding box covering the logical bounds of the specified text.
1089 * @throws IndexOutOfBoundsException if the range [begin, limit] is
1090 * invalid in <code>chars</code>.
1094 * @see createGlyphVector()
1097 getStringBounds(char[] chars
, int begin
, int limit
, FontRenderContext frc
)
1099 throw new UnsupportedOperationException ();
1103 * Returns a copy of the affine transformation this font is currently
1104 * subject to, if any.
1106 * @return The current transformation.
1108 public AffineTransform
1111 throw new UnsupportedOperationException ();
1115 * Indicates whether this font's line metrics are uniform. A font may be
1116 * composed of several "subfonts", each covering a different code range,
1117 * and each with their own line metrics. A font with no subfonts, or
1118 * subfonts with identical line metrics, is said to have "uniform" line
1121 * @return Whether this font has uniform line metrics.
1124 * @see getLineMetrics()
1127 hasUniformLineMetrics()
1129 throw new UnsupportedOperationException ();
1133 * Indicates whether this font is subject to a non-identity affine
1136 * @return <code>true</code> iff the font has a non-identity affine
1137 * transformation applied to it.
1142 throw new UnsupportedOperationException ();
1146 * Produces a glyph vector representing a full layout fo the specified
1147 * text in this font. Full layouts may include complex shaping and
1148 * reordering operations, for scripts such as Arabic or Hindi.
1150 * Bidirectional (bidi) layout is not performed in this method; text
1151 * should have its bidi direction specified with one of the flags {@link
1152 * LAYOUT_LEFT_TO_RIGHT} or {@link LAYOUT_RIGHT_TO_LEFT}.
1154 * Some types of layout (notably Arabic glyph shaping) may examine context
1155 * characters beyond the bounds of the indicated range, in order to select
1156 * an appropriate shape. The flags {@link LAYOUT_NO_START_CONTEXT} and
1157 * {@link LAYOUT_NO_LIMIT_CONTEXT} can be provided to prevent these extra
1158 * context areas from being examined, for instance if they contain invalid
1161 * @param frc Context in which to perform the layout.
1162 * @param chars Text to perform layout on.
1163 * @param start Index of first character to perform layout on.
1164 * @param limit Index of last character to perform layout on.
1165 * @param flags Combination of flags controlling layout.
1167 * @return A new {@link GlyphVector} representing the specified text.
1169 * @throws IndexOutOfBoundsException if the range [begin, limit] is
1170 * invalid in <code>chars</code>.
1173 layoutGlyphVector(FontRenderContext frc
, char[] chars
, int start
, int limit
, int flags
)
1175 throw new UnsupportedOperationException ();
1179 /*************************************************************************/
1182 * Returns a native peer object for this font.
1184 * @return A native peer object for this font.
1194 peer
= Toolkit
.getDefaultToolkit().getFontPeer(name
, style
);
1198 /*************************************************************************/
1201 * Returns a hash value for this font.
1203 * @return A hash for this font.
1208 return((new String(name
+ size
+ style
)).hashCode());
1211 /*************************************************************************/
1214 * Tests whether or not the specified object is equal to this font. This
1215 * will be true if and only if:
1218 * <li>The object is not <code>null</code>.
1219 * <li>The object is an instance of <code>Font</code>.
1220 * <li>The object has the same name, style, and size as this object.
1223 * @return <code>true</code> if the specified object is equal to this
1224 * object, <code>false</code> otherwise.
1229 if (!(obj
instanceof Font
))
1234 if (!f
.name
.equals(name
))
1240 if (f
.style
!= style
)
1246 /*************************************************************************/
1249 * Returns a string representation of this font.
1251 * @return A string representation of this font.
1256 return(getClass().getName() + "(name=" + name
+ ",style=" + style
+
1257 ",size=" + size
+ ")");
1262 * Determines the line metrics for a run of text.
1264 * @param str the text run to be measured.
1266 * @param frc the font rendering parameters that are used for the
1267 * measurement. The exact placement and size of text slightly
1268 * depends on device-specific characteristics, for instance
1269 * the device resolution or anti-aliasing. For this reason,
1270 * the returned measurement will only be accurate if the
1271 * passed <code>FontRenderContext</code> correctly reflects
1272 * the relevant parameters. Hence, <code>frc</code> should be
1273 * obtained from the same <code>Graphics2D</code> that will
1274 * be used for drawing, and any rendering hints should be set
1275 * to the desired values before obtaining <code>frc</code>.
1277 * @see java.awt.Graphics2D#getFontRenderContext()
1279 public LineMetrics
getLineMetrics(String str
, FontRenderContext frc
)
1281 throw new UnsupportedOperationException(); // FIXME