|
PDAP Public Review Draft | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.awt.Font
The Font
class represents fonts. The capabilities of this
class have been extended over the java.awt.Font class in JDK(tm) 1.1
and earlier releases to provide for developers the ability to utilize
more sophisticated typographic features.
It is important to present the concepts behind using the words character and glyph separately. A character is a symbol that represents items like letters and numbers in a particular writing system. For example, lowercase-g is a character. When a particular character has been rendered, a shape now represents this character. This shape is called a glyph.
Chararcter encoding is a conversion table that maps character codes to glyph codes in the font. The character encoding used in the Java 2D(tm) API is Unicode. For more information on Unicode you can visit the site http://www.unicode.org.
Characters and glyphs do not have one-to-one correspondence. For example, lowercase-a acute can be represented by two glyphs: lowercase-a and acute. Another example is ligatures such as ligature -fi which is a single glyph representing two characters, f and i.
A Font
is a collection of glyphs. A Font
can have many faces, such as heavy, medium, oblique, gothic and
regular. All of these faces have similar typographic design.
There are three different names that you can get from a
Font
object. The logical font name is the same as
that used by java.awt.Font in JDK 1.1 and earlier releases.
The font face name, or just font name for
short, is the name of a particular font face, like Helvetica Bold. The
family name is the name of the font family that determines the
typographic design across several faces, like Helvetica. The font face
name is the one that should be used to specify fonts. This name
signifies actual fonts in the host system, and does not identify font
names with the shape of font characters as the logical font name does.
The Font
class represents an instance of a font face from
a collection of font faces that are present in the system resources
of the host system. As examples, Arial Bold and Courier Bold Italic
are font faces. There can be several Font
objects
associated with a font face, each differing in size, style, transform
and font features.
Field Summary | |
static int |
BOLD
The bold style constant. |
static int |
ITALIC
The italicized style constant. |
protected java.lang.String |
name
The logical name of this Font , as passed to the
constructor. |
static int |
PLAIN
The plain style constant. |
protected int |
size
The point size of this Font , rounded to integer. |
protected int |
style
The style of this Font , as passed to the constructor. |
Constructor Summary | |
Font(java.lang.String name,
int style,
int size)
Creates a new Font from the specified name, style and
point size. |
Method Summary | |
static Font |
decode(java.lang.String str)
Returns the Font that the
str argument describes. |
boolean |
equals(java.lang.Object obj)
Compares this Font object to the specified
Object . |
java.lang.String |
getFamily()
Returns the family name of this Font . |
static Font |
getFont(java.lang.String nm)
Returns a Font object from the system properties list. |
static Font |
getFont(java.lang.String nm,
Font font)
Gets the specified Font from the system properties
list. |
java.lang.String |
getName()
Returns the logical name of this Font . |
int |
getSize()
Returns the point size of this Font , rounded to
an integer. |
int |
getStyle()
Returns the style of this Font . |
int |
hashCode()
Returns a hashcode for this Font . |
boolean |
isBold()
Indicates whether or not this Font object's style is
BOLD. |
boolean |
isItalic()
Indicates whether or not this Font object's style is
ITALIC. |
boolean |
isPlain()
Indicates whether or not this Font object's style is
PLAIN. |
java.lang.String |
toString()
Converts this Font object to a String
representation. |
Methods inherited from class java.lang.Object |
getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final int PLAIN
Value 0 is assigned to PLAIN.
public static final int BOLD
Value 1 is assigned to BOLD.
public static final int ITALIC
Value 2 is assigned to ITALIC.
protected java.lang.String name
Font
, as passed to the
constructor.getName()
protected int style
Font
, as passed to the constructor.
This style can be PLAIN, BOLD, ITALIC, or BOLD+ITALIC.getStyle()
protected int size
Font
, rounded to integer.getSize()
Constructor Detail |
public Font(java.lang.String name, int style, int size)
Font
from the specified name, style and
point size.name
- the font name. This can be a logical font name or a
font face name. A logical name must be either: Dialog, DialogInput,
Monospaced, Serif, SansSerif, or Symbol. If name
is
null
, the name
of the new
Font
is set to Default.style
- the style constant for the Font
The style argument is an integer bitmask that may
be PLAIN, or a bitwise union of BOLD and/or ITALIC
(for example, ITALIC or BOLD|ITALIC). Any other
bits set in the style parameter are ignored.
If the style argument does not conform to one of the expected
integer bitmasks then the style is set to PLAIN.size
- the point size of the Font
GraphicsEnvironment.getAvailableFontFamilyNames()
Method Detail |
public java.lang.String getFamily()
Font
. For example,
Helvetica could be returned as a family name for the font
face name of Helvetica Bold.
Use getName
to get the logical name of the font.String
that is the family name of this
Font
.getName()
public java.lang.String getName()
Font
.
Use getFamily
to get the family name of the font.String
representing the logical name of
this Font
.getFamily()
public int getStyle()
Font
. The style can be
PLAIN, BOLD, ITALIC, or BOLD+ITALIC.Font
isPlain()
,
isBold()
,
isItalic()
public int getSize()
Font
, rounded to
an integer.
Most users are familiar with the idea of using point size to
specify the size of glyphs in a font. This point size defines a
measurement between the baseline of one line to the baseline of the
following line in a single spaced text document. The point size is
based on typographic points, approximately 1/72 of an inch.Font
in 1/72 of an
inch units.public boolean isPlain()
Font
object's style is
PLAIN.true
if this Font
has a
PLAIN sytle;
false
otherwise.getStyle()
public boolean isBold()
Font
object's style is
BOLD.true
if this Font
object's
style is BOLD;
false
otherwise.getStyle()
public boolean isItalic()
Font
object's style is
ITALIC.true
if this Font
object's
style is ITALIC;
false
otherwise.getStyle()
public static Font getFont(java.lang.String nm)
Font
object from the system properties list.nm
- the property nameFont
object that the property name
describes.public static Font decode(java.lang.String str)
Font
that the
str
argument describes.
To ensure that this method returns the desired Font,
format the str
parameter in
one of two ways:
"fontfamilyname-style-pointsize" or
"fontfamilyname style pointsize"
in which style is one of the three
case-insensitive strings:
"BOLD"
, "BOLDITALIC"
, or
"ITALIC"
, and pointsize is a decimal
representation of the point size.
For example, if you want a font that is Arial, bold, and
a point size of 18, you would call this method with:
"Arial-BOLD-18".
The default size is 12 and the default style is PLAIN.
If you don't specify a valid size, the returned
Font
has a size of 12. If you don't specify
a valid style, the returned Font has a style of PLAIN.
If you do not provide a valid font family name in
the str
argument, this method still returns
a valid font with a family name of "dialog".
To determine what font family names are available on
your system, use the
GraphicsEnvironment.getAvailableFontFamilyNames()
method.
If str
is null
, a new Font
is returned with the family name "dialog", a size of 12 and a
PLAIN style.
str
- the name of the font, or null
Font
object that str
describes, or a new default Font
if
str
is null
.getFamily()
public static Font getFont(java.lang.String nm, Font font)
Font
from the system properties
list. As in the getProperty
method of
System
, the first
argument is treated as the name of a system property to be
obtained. The String
value of this
property is then interpreted as a Font
object.
The property value should be one of the following forms:
"BOLD"
, "BOLDITALIC"
, or
"ITALIC"
, and point size is a decimal
representation of the point size.
The default style is PLAIN
. The default point size
is 12.
If the specified property is not found, the font
argument is returned instead.
nm
- the case-insensitive property namefont
- a default Font
to return if property
nm
is not definedFont
value of the property.decode(String)
public int hashCode()
Font
.hashCode
in class java.lang.Object
Font
.public boolean equals(java.lang.Object obj)
Font
object to the specified
Object
.equals
in class java.lang.Object
obj
- the Object
to compare.true
if the objects are the same;
false
otherwise.public java.lang.String toString()
Font
object to a String
representation.toString
in class java.lang.Object
String
representation of this
Font
object.
|
PDAP 1.0 Spec, Rev. 0.16 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |