Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
java.lang.Object
java.awt.Font
Field Summary | |
static int |
|
static int |
|
static String | |
static String | |
static int |
|
static int |
|
static int |
|
static int |
|
static int |
|
static int |
|
static String | |
static int |
|
static int |
|
static String | |
static String | |
static int |
|
static int |
|
protected String |
|
protected float |
|
protected int |
|
protected int |
|
Constructor Summary | |
| |
Method Summary | |
Map |
|
boolean |
|
boolean |
|
int |
|
int |
|
int |
|
static Font |
|
static Font |
|
GlyphVector |
|
GlyphVector |
|
GlyphVector |
|
GlyphVector |
|
static Font | |
Font |
|
Font |
|
Font |
|
Font |
|
Font |
|
Font |
|
boolean | |
AttributedCharacterIterator.Attribute[] |
|
byte |
|
String |
|
String | |
static Font |
|
static Font | |
static Font | |
String |
|
String |
|
float |
|
LineMetrics |
|
LineMetrics |
|
LineMetrics |
|
LineMetrics |
|
Rectangle2D |
|
int |
|
String |
|
int |
|
String |
|
FontPeer |
|
int |
|
float |
|
Rectangle2D |
|
Rectangle2D |
|
Rectangle2D |
|
Rectangle2D |
|
int | |
AffineTransform |
|
boolean | |
boolean |
|
int |
|
boolean |
|
boolean |
|
boolean |
|
boolean |
|
GlyphVector |
|
String |
|
Methods inherited from class java.lang.Object | |
clone , equals , extends Object> getClass , finalize , hashCode , notify , notifyAll , toString , wait , wait , wait |
public static final int CENTER_BASELINE
Constant indicating the baseline mode characteristic of Chinese.
- Field Value:
- 1
public static final int HANGING_BASELINE
Constant indicating the baseline mode characteristic of Devanigri.
- Field Value:
- 2
public static final int LAYOUT_LEFT_TO_RIGHT
A flag forlayoutGlyphVector
, indicating that the orientation of a text run is from left to right.
- Field Value:
- 0
- Since:
- 1.4
public static final int LAYOUT_NO_LIMIT_CONTEXT
A flag forlayoutGlyphVector
, indicating that the text does not contain valid characters after thelimit
position. If this flag is set,layoutGlyphVector
does not examine the text afterlimit
, even if this would be necessary to select the correct glyphs (e.g., for Arabic text).
- Field Value:
- 4
- Since:
- 1.4
public static final int LAYOUT_NO_START_CONTEXT
A flag forlayoutGlyphVector
, indicating that the text does not contain valid characters before thestart
position. If this flag is set,layoutGlyphVector
does not examine the text beforestart
, even if this would be necessary to select the correct glyphs (e.g., for Arabic text).
- Field Value:
- 2
- Since:
- 1.4
public static final int LAYOUT_RIGHT_TO_LEFT
A flag forlayoutGlyphVector
, indicating that the orientation of a text run is from right to left.
- Field Value:
- 1
- Since:
- 1.4
public static final int ROMAN_BASELINE
Constant indicating the baseline mode characteristic of Roman.
- Field Value:
- 0
public static final int TRUETYPE_FONT
Indicates tocreateFont
that the supplied font data is in TrueType format. Specification Note: The Sun JavaDoc for J2SE 1.4 does not indicate whether this value also subsumes OpenType. OpenType is essentially the same format as TrueType, but allows to define glyph shapes in the same way as PostScript, using cubic bezier curves.
- Field Value:
- 0
- Since:
- 1.3
public static final int TYPE1_FONT
Indicates tocreateFont
that the supplied font data is in Type1 format.
- Field Value:
- 1
- Since:
- 1.5
public Map?> getAttributes()
Returns a map of chracter attributes which this font currently has set.
- Returns:
- A map of chracter attributes which this font currently has set.
public boolean canDisplay(char c)
Checks if specified character maps to a glyph in this font.
- Parameters:
c
- The character to check.
- Returns:
- Whether the character has a corresponding glyph in this font.
- Since:
- 1.2
public int canDisplayUpTo(char[] text, int start, int limit)
Checks how much of a given sequence of text can be mapped to glyphs in this font.
- Parameters:
text
- Array containing the text to check.start
- Position of first character to check intext
.limit
- Position of last character to check intext
.
- Returns:
- The index of the first character in the indicated range which cannot be converted to a glyph by this font, or
-1
if all characters can be mapped to glyphs.
- Throws:
IndexOutOfBoundsException
- if the range [start, limit] is invalid intext
.
- Since:
- 1.2
public int canDisplayUpTo(String s)
Checks how much of a given string can be mapped to glyphs in this font.
- Parameters:
s
- The string to check.
- Returns:
- The index of the first character in
s
which cannot be converted to a glyph by this font, or-1
if all characters can be mapped to glyphs.
- Since:
- 1.2
public int canDisplayUpTo(CharacterIterator i, int start, int limit)
Checks how much of a given sequence of text can be mapped to glyphs in this font.
- Parameters:
i
- Iterator over the text to check.start
- Position of first character to check ini
.limit
- Position of last character to check ini
.
- Returns:
- The index of the first character in the indicated range which cannot be converted to a glyph by this font, or
-1
if all characters can be mapped to glyphs.
- Throws:
IndexOutOfBoundsException
- if the range [start, limit] is invalid ini
.
- Since:
- 1.2
public static Font createFont(int fontFormat, File file) throws FontFormatException, IOException
Creates a new font from a File object.
- Parameters:
fontFormat
- - Integer code indicating the format the font data is in.Currently this can only beTRUETYPE_FONT
.file
- - aFile
from which font data will be read.
- Returns:
- A new
Font
of the format indicated.
- Throws:
IllegalArgumentException
- iffontType
is not recognized.NullPointerException
- iffile
isnull
.FontFormatException
- if data in the file is invalid or cannot be read..SecurityException
- if the caller has no read permission for the file.IOException
- if the file cannot be read
- Since:
- 1.5
public static Font createFont(int fontFormat, InputStream is) throws FontFormatException, IOException
Creates a new font with point size 1 andPLAIN
style, reading font data from the provided input stream. The resulting font can have further fonts derived from it using itsderiveFont
method.
- Parameters:
fontFormat
- Integer code indicating the format the font data is in.Currently this can only beTRUETYPE_FONT
.is
-InputStream
from which font data will be read. This stream is not closed after font data is extracted.
- Returns:
- A new
Font
of the format indicated.
- Throws:
IllegalArgumentException
- iffontType
is not recognized.FontFormatException
- if data in InputStream is not of format indicated.IOException
- if insufficient data is present on InputStream.
- Since:
- 1.3
public GlyphVector createGlyphVector(FontRenderContext ctx, char[] chars)
Maps characters to glyphs in a one-to-one relationship, returning a newGlyphVector
with a mapped glyph for each input character. This sort of mapping is often sufficient for some scripts such as Roman, but is inappropriate for scripts with special shaping or contextual layout requirements such as Arabic, Indic, Hebrew or Thai.
- Parameters:
ctx
- The rendering context used for precise glyph placement.chars
- Array of characters to convert to glyphs.
- Returns:
- A new
GlyphVector
containing glyphs mapped from str, through the font's cmap table.
public GlyphVector createGlyphVector(FontRenderContext ctx, int[] glyphCodes)
Extracts a sequence of glyphs from a font, returning a newGlyphVector
with a mapped glyph for each input glyph code.
- Parameters:
ctx
- The rendering context used for precise glyph placement.glyphCodes
- Array of characters to convert to glyphs.
- Returns:
- A new
GlyphVector
containing glyphs mapped from str, through the font's cmap table.
public GlyphVector createGlyphVector(FontRenderContext ctx, String str)
Maps characters to glyphs in a one-to-one relationship, returning a newGlyphVector
with a mapped glyph for each input character. This sort of mapping is often sufficient for some scripts such as Roman, but is inappropriate for scripts with special shaping or contextual layout requirements such as Arabic, Indic, Hebrew or Thai.
- Parameters:
ctx
- The rendering context used for precise glyph placement.str
- The string to convert to Glyphs.
- Returns:
- A new
GlyphVector
containing glyphs mapped from str, through the font's cmap table.
public GlyphVector createGlyphVector(FontRenderContext ctx, CharacterIterator i)
Maps characters to glyphs in a one-to-one relationship, returning a newGlyphVector
with a mapped glyph for each input character. This sort of mapping is often sufficient for some scripts such as Roman, but is inappropriate for scripts with special shaping or contextual layout requirements such as Arabic, Indic, Hebrew or Thai.
- Parameters:
ctx
- The rendering context used for precise glyph placement.i
- Iterator over the text to convert to glyphs.
- Returns:
- A new
GlyphVector
containing glyphs mapped from str, through the font's cmap table.
public static Font decode(String fontspec)
Creates aFont
object from the specified string, which is in one of the following formats:The style should be one of BOLD, ITALIC, or BOLDITALIC. The default style if none is specified is PLAIN. The default size if none is specified is 12.
- fontname-style-pointsize
- fontname-style
- fontname-pointsize
- fontname
- Parameters:
fontspec
- a string specifying the required font (null
permitted, interpreted as 'Dialog-PLAIN-12').
- Returns:
- A font.
public Font deriveFont(extends AttributedCharacterIterator.Attribute, ?> attributes)
Produces a newFont
based on the current font, adjusted to a new set of attributes.
- Parameters:
attributes
- Attributes of the newly created font.
- Returns:
- A clone of the current font, with the specified attributes.
- Since:
- 1.2
public Font deriveFont(float size)
Produces a newFont
based on the current font, adjusted to a new size.
- Parameters:
size
- The size of the newly created font.
- Returns:
- A clone of the current font, with the specified size.
- Since:
- 1.2
public Font deriveFont(int style)
Produces a newFont
based on the current font, adjusted to a new style.
- Parameters:
style
- The style of the newly created font.
- Returns:
- A clone of the current font, with the specified style.
- Since:
- 1.2
public Font deriveFont(int style, float size)
Produces a newFont
based on the current font, adjusted to a new size and style.
- Parameters:
style
- The style of the newly created font.size
- The size of the newly created font.
- Returns:
- A clone of the current font, with the specified size and style.
- Since:
- 1.2
public Font deriveFont(int style, AffineTransform a)
Produces a newFont
based on the current font, adjusted to a new style and subjected to a new affine transformation.
- Parameters:
style
- The style of the newly created font.a
- The transformation to apply.
- Returns:
- A clone of the current font, with the specified style and transform.
- Throws:
IllegalArgumentException
- If transformation isnull
.
- Since:
- 1.2
public Font deriveFont(AffineTransform a)
Produces a newFont
based on the current font, subjected to a new affine transformation.
- Parameters:
a
- The transformation to apply.
- Returns:
- A clone of the current font, with the specified transform.
- Throws:
IllegalArgumentException
- If transformation isnull
.
- Since:
- 1.2
public boolean equals(Object obj)
Tests whether or not the specified object is equal to this font. This will be true if and only if:
- The object is not
null
.- The object is an instance of
Font
.- The object has the same names, style, size, and transform as this object.
- Returns:
true
if the specified object is equal to this object,false
otherwise.
public AttributedCharacterIterator.Attribute[] getAvailableAttributes()
Returns an array of chracter attribute keys which this font understands.
- Returns:
- An array of chracter attribute keys which this font understands.
- See Also:
getAttributes()
,AttributedCharacterIterator.Attribute
,TextAttribute
public byte getBaselineFor(char c)
Returns a baseline code (one ofROMAN_BASELINE
,CENTER_BASELINE
orHANGING_BASELINE
) indicating which baseline this font will measure baseline offsets for, when presenting glyph metrics for a given character. Baseline offsets describe the position of a glyph relative to an invisible line drawn under, through the center of, or over a line of rendered text, respectively. Different scripts use different baseline modes, so clients should not assume all baseline offsets in a glyph vector are from a common baseline.
- Parameters:
c
- The character code to select a baseline mode for.
- Returns:
- The baseline mode which would be used in a glyph associated with the provided character.
- Since:
- 1.2
- See Also:
LineMetrics.getBaselineOffsets()
public String getFamily()
Returns the family name of this font. A family name describes a design or "brand name" (such as Helvetica or Palatino). It is less specific than a font face name (such as Helvetica Bold).
- Returns:
- A string containing the font family name.
- Since:
- 1.2
public String getFamily(Locale lc)
Returns the family name of this font. A family name describes a typographic style (such as Helvetica or Palatino). It is more specific than a logical font name (such as Sans Serif) but less specific than a font face name (such as Helvetica Bold).
- Parameters:
lc
- The locale in which to describe the name of the font family.
- Returns:
- A string containing the font family name, localized for the provided locale.
- Since:
- 1.2
public static Font getFont(extends AttributedCharacterIterator.Attribute, ?> attributes)
Returns a font appropriate for the given attribute set.
- Parameters:
attributes
- The attributes required for the new font.
- Returns:
- A new Font with the given attributes.
- Since:
- 1.2
- See Also:
TextAttribute
public static Font getFont(String propname)
Returns aFont
object from the passed property name.
- Parameters:
propname
- The name of the system property.
- Returns:
- The requested font, or
null
if the property not exist or is malformed.
public static Font getFont(String propname, Font defval)
Returns aFont
object from the passed property name.
- Parameters:
propname
- The name of the system property.defval
- Value to use if the property is not found.
- Returns:
- The requested font, or
default
if the property not exist or is malformed.
public String getFontName()
Returns the font face name of the font. A font face name describes a specific variant of a font family (such as Helvetica Bold). It is more specific than both a font family name (such as Helvetica) and a logical font name (such as Sans Serif).
- Returns:
- The font face name of the font.
- Since:
- 1.2
- See Also:
getName()
,getFamily()
public String getFontName(Locale lc)
Returns the font face name of the font. A font face name describes a specific variant of a font family (such as Helvetica Bold). It is more specific than both a font family name (such as Helvetica).
- Parameters:
lc
- The locale in which to describe the name of the font face.
- Returns:
- A string containing the font face name, localized for the provided locale.
- Since:
- 1.2
- See Also:
getName()
,getFamily()
public float getItalicAngle()
Returns the italic angle of this font, a measurement of its slant when style isITALIC
. The precise meaning is the inverse slope of a caret line which "best measures" the font's italic posture.
- Returns:
- The italic angle.
- See Also:
TextAttribute.POSTURE
public LineMetrics getLineMetrics(char[] chars, int begin, int limit, FontRenderContext rc)
Returns aLineMetrics
object constructed with the specified text andFontRenderContext
.
- Parameters:
chars
- The string to calculate metrics from.begin
- Index of first character intext
to measure.limit
- Index of last character intext
to measure.rc
- Context for calculating precise glyph placement and hints.
- Returns:
- A new
LineMetrics
object.
- Throws:
IndexOutOfBoundsException
- if the range [begin, limit] is invalid inchars
.
public LineMetrics getLineMetrics(String text, int begin, int limit, FontRenderContext rc)
Returns aLineMetrics
object constructed with the specified text andFontRenderContext
.
- Parameters:
text
- The string to calculate metrics from.begin
- Index of first character intext
to measure.limit
- Index of last character intext
to measure.rc
- Context for calculating precise glyph placement and hints.
- Returns:
- A new
LineMetrics
object.
- Throws:
IndexOutOfBoundsException
- if the range [begin, limit] is invalid intext
.
public LineMetrics getLineMetrics(String str, FontRenderContext frc)
Determines the line metrics for a run of text.
- Parameters:
str
- the text run to be measured.frc
- the font rendering parameters that are used for the measurement. The exact placement and size of text slightly depends on device-specific characteristics, for instance the device resolution or anti-aliasing. For this reason, the returned measurement will only be accurate if the passedFontRenderContext
correctly reflects the relevant parameters. Hence,frc
should be obtained from the sameGraphics2D
that will be used for drawing, and any rendering hints should be set to the desired values before obtainingfrc
.
- See Also:
Graphics2D.getFontRenderContext()
public LineMetrics getLineMetrics(CharacterIterator ci, int begin, int limit, FontRenderContext rc)
Returns aLineMetrics
object constructed with the specified text andFontRenderContext
.
- Parameters:
ci
- The string to calculate metrics from.begin
- Index of first character intext
to measure.limit
- Index of last character intext
to measure.rc
- Context for calculating precise glyph placement and hints.
- Returns:
- A new
LineMetrics
object.
- Throws:
IndexOutOfBoundsException
- if the range [begin, limit] is invalid inci
.
public Rectangle2D getMaxCharBounds(FontRenderContext rc)
Returns the maximal bounding box of all the bounding boxes in this font, when the font's bounding boxes are evaluated in a givenFontRenderContext
- Parameters:
rc
- Context in which to evaluate bounding boxes.
- Returns:
- The maximal bounding box.
public int getMissingGlyphCode()
Returns the glyph code this font uses to represent missing glyphs. This code will be present in glyph vectors when the font was unable to locate a glyph to represent a particular character code.
- Returns:
- The missing glyph code.
- Since:
- 1.2
public String getName()
Returns the logical name of the font. A logical name is the name the font was constructed with. It may be the name of a logical font (one of 6 required names in all java environments) or it may be a face name.
- Returns:
- The logical name of the font.
- See Also:
getFamily()
,getFontName()
public int getNumGlyphs()
Returns the overall number of glyphs in this font. This number is one more than the greatest glyph code used in any glyph vectors this font produces. In other words, glyph codes are taken from the range[ 0, getNumGlyphs() - 1 ]
.
- Returns:
- The number of glyphs in this font.
- Since:
- 1.2
public String getPSName()
Returns the PostScript Name of this font.
- Returns:
- The PostScript Name of this font.
- Since:
- 1.2
- See Also:
getName()
,getFamily()
,getFontName()
public FontPeer getPeer()
Deprecated.
Returns a native peer object for this font.
- Returns:
- A native peer object for this font.
public int getSize()
Returns the size of the font, in typographics points (1/72 of an inch), rounded to an integer.
- Returns:
- The font size
public float getSize2D()
Returns the size of the font, in typographics points (1/72 of an inch).
- Returns:
- The font size
public Rectangle2D getStringBounds(char[] chars, int begin, int limit, FontRenderContext frc)
Returns the logical bounds of the specified string when rendered with this font in the specifiedFontRenderContext
. This box will include the glyph origin, ascent, advance, height, and leading, but may not include all diacritics or accents. To get the complete visual bounding box of all the glyphs in a run of text, use theTextLayout.getBounds()
method ofTextLayout
.
- Parameters:
chars
- The text to measure.begin
- Index of the first character inci
to measure.limit
- Index of the last character inci
to measure.frc
- The context in which to make the precise glyph measurements.
- Returns:
- A bounding box covering the logical bounds of the specified text.
- Throws:
IndexOutOfBoundsException
- if the range [begin, limit] is invalid inchars
.
- Since:
- 1.2
public Rectangle2D getStringBounds(String str, int begin, int limit, FontRenderContext frc)
Returns the logical bounds of the specified string when rendered with this font in the specifiedFontRenderContext
. This box will include the glyph origin, ascent, advance, height, and leading, but may not include all diacritics or accents. To get the complete visual bounding box of all the glyphs in a run of text, use theTextLayout.getBounds()
method ofTextLayout
.
- Parameters:
str
- The string to measure.begin
- Index of the first character instr
to measure.limit
- Index of the last character instr
to measure.frc
- The context in which to make the precise glyph measurements.
- Returns:
- A bounding box covering the logical bounds of the specified text.
- Throws:
IndexOutOfBoundsException
- if the range [begin, limit] is invalid instr
.
- Since:
- 1.2
public Rectangle2D getStringBounds(String str, FontRenderContext frc)
Returns the logical bounds of the specified string when rendered with this font in the specifiedFontRenderContext
. This box will include the glyph origin, ascent, advance, height, and leading, but may not include all diacritics or accents. To get the complete visual bounding box of all the glyphs in a run of text, use theTextLayout.getBounds()
method ofTextLayout
.
- Parameters:
str
- The string to measure.frc
- The context in which to make the precise glyph measurements.
- Returns:
- A bounding box covering the logical bounds of the specified text.
public Rectangle2D getStringBounds(CharacterIterator ci, int begin, int limit, FontRenderContext frc)
Returns the logical bounds of the specified string when rendered with this font in the specifiedFontRenderContext
. This box will include the glyph origin, ascent, advance, height, and leading, but may not include all diacritics or accents. To get the complete visual bounding box of all the glyphs in a run of text, use theTextLayout.getBounds()
method ofTextLayout
.
- Parameters:
ci
- The text to measure.begin
- Index of the first character inci
to measure.limit
- Index of the last character inci
to measure.frc
- The context in which to make the precise glyph measurements.
- Returns:
- A bounding box covering the logical bounds of the specified text.
- Throws:
IndexOutOfBoundsException
- if the range [begin, limit] is invalid inci
.
- Since:
- 1.2
public int getStyle()
Returns integer code representing the sum of style flags of this font, a combination of eitherPLAIN
,BOLD
, orITALIC
.
- Returns:
- code representing the style of this font.
- See Also:
isPlain()
,isBold()
,isItalic()
public AffineTransform getTransform()
Returns a copy of the affine transformation this font is currently subject to, if any.
- Returns:
- The current transformation.
public boolean hasUniformLineMetrics()
Indicates whether this font's line metrics are uniform. A font may be composed of several "subfonts", each covering a different code range, and each with their own line metrics. A font with no subfonts, or subfonts with identical line metrics, is said to have "uniform" line metrics.
- Returns:
- Whether this font has uniform line metrics.
public boolean isBold()
Tests whether or not this font is bold.
- Returns:
true
if this font is bold,false
otherwise.
public boolean isItalic()
Tests whether or not this font is italic.
- Returns:
true
if this font is italic,false
otherwise.
public boolean isPlain()
Tests whether or not this is a plain font. This will be true if and only if neither the bold nor the italics style is set.
- Returns:
true
if this is a plain font,false
otherwise.
public boolean isTransformed()
Indicates whether this font is subject to a non-identity affine transformation.
- Returns:
true
iff the font has a non-identity affine transformation applied to it.
public GlyphVector layoutGlyphVector(FontRenderContext frc, char[] chars, int start, int limit, int flags)
Produces a glyph vector representing a full layout fo the specified text in this font. Full layouts may include complex shaping and reordering operations, for scripts such as Arabic or Hindi. Bidirectional (bidi) layout is not performed in this method; text should have its bidi direction specified with one of the flagsLAYOUT_LEFT_TO_RIGHT
orLAYOUT_RIGHT_TO_LEFT
. Some types of layout (notably Arabic glyph shaping) may examine context characters beyond the bounds of the indicated range, in order to select an appropriate shape. The flagsLAYOUT_NO_START_CONTEXT
andLAYOUT_NO_LIMIT_CONTEXT
can be provided to prevent these extra context areas from being examined, for instance if they contain invalid characters.
- Parameters:
frc
- Context in which to perform the layout.chars
- Text to perform layout on.start
- Index of first character to perform layout on.limit
- Index of last character to perform layout on.flags
- Combination of flags controlling layout.
- Returns:
- A new
GlyphVector
representing the specified text.
- Throws:
IndexOutOfBoundsException
- if the range [begin, limit] is invalid inchars
.