Packages  This Package  Prev  Next  Index  

§1.17 Class Font

public  class  java.awt.Font
    extends  java.lang.Object  (I-§1.12)
{
        // Fields
    protected String name;	§1.17.1
    protected int size;	§1.17.2
    protected int style;	§1.17.3

        // style has the following bit masks
    public final static int BOLD;	§1.17.4
    public final static int ITALIC;	§1.17.5
    public final static int PLAIN	§1.17.6

        // Constructors
    public Font(String  name, int  style, int  size);	§1.17.7

        // Methods
    public boolean equals(Object  obj);	§1.17.8
    public String getFamily();	§1.17.9
    public static Font getFont(String  nm);	§1.17.10
    public static Font getFont(String  nm, Font  font);	§1.17.11
    public String getName();	§1.17.12
    public int getSize();	§1.17.13
    public int getStyle();	§1.17.14
    public int hashCode();	§1.17.15
    public boolean isBold();	§1.17.16
    public boolean isItalic();	§1.17.17
    public boolean isPlain();	§1.17.18
    public String toString();	§1.17.19
}
This class represents a font.


Fields

name

protected String name
The logical name of this font.

size

protected int size
The point size of this font.

style

protected int style
The style of the font. This is the sum of the constants PLAIN, BOLD, or ITALIC.

BOLD

public final static int BOLD = 1
The bold style constant. This can be combined with the other style constants for mixed styles.

ITALIC

public final static int ITALIC = 2
The italicized style constant. This can be combined with the other style constants for mixed styles.

PLAIN

public final static int PLAIN = 0
The plain style constant. This can be combined with the other style constants for mixed styles.

Constructors

Font

public Font(String name, int style, int size)
Creates a new font with the specified name, style, and point size.
Parameters:
name - the font name
style - the constant style used
size - the point size of the font
See Also:
getFontList in class Toolkit (II-§1.41.24).

Methods

equals

public boolean equals(Object obj)
The result is true if and only if the argument is not null and is a Font object with the same name, same style, and same point size as this Font..
Parameters:
obj - the object to compare with
Returns:
true if the objects are the same; false otherwise.
Overrides:
equals in class Object (I-§1.12.3).

getFamily

public String getFamily()
Returns:
the platform-specific family name of this font.
See Also:
getName (II-§1.17.12).

getFont

public static Font getFont(String nm)
The first argument is treated as the name of a system property to be obtained as if by the method System.getProperty (I-§1.18.10). The string value of this property is then interpreted as a font as described in the getFont method of two argument (II-§1.17.11).


If the specified property is not found, null is returned.
Parameters:
nm - the property name
Returns:
the Font value of the property.

getFont

public static Font getFont(String nm, Font font)
The first argument is treated as the name of a system property to be obtained as if by the method System.getProperty (I-§1.18.10). The string value of this property is then interpreted as a font.


The property value should be one of the following forms:
fontname-style-pointsize
fontname-pointsize
fontname-style
fontname
where style is one of the three strings "bold", "bolditalic" or "italic" and pointsize is a decimal representation of the pointsize.
The default style is PLAIN. The default pointsize is 12.
If the specified property is not found, the font argument is returned instead.
Parameters:
nm - the property name
font - a default font to return if property 'nm' is not defined
Parameters:
nm - the property name
font - a default font to return if the property isn't defined
Returns:
the Font value of the property.

getName

public String getName()
Returns:
the logical name of this font.
See Also:
getFamily (II-§1.17.9).

getSize

public int getSize()
Returns:
the point size of this font.

getStyle

public int getStyle()
Returns:
the style of this font.
See Also:
isPlain (II-§1.17.18)
isBold (II-§1.17.16)
isItalic (II-§1.17.17).

hashCode

public int hashCode()
Returns:
a hash code value for this font.
Overrides:
hashCode in class Object (I-§1.12.6).

isBold

public boolean isBold()
Returns:
true if this font is bold; false otherwise.
See Also:
getStyle (II-§1.17.16).

isItalic

public boolean isItalic()
Returns:
true if this font is italic; false otherwise.
See Also:
getStyle (II-§1.17.16).

isPlain

public boolean isPlain()
Returns:
true if this font is neither bold nor italic; false otherwise.
See Also:
getStyle (II-§1.17.16).

toString

public String toString()
Returns:
a string representation of this font.
Overrides:
toString in class Object (I-§1.12.9).

Packages  This Package  Prev  Next  Index
Java API Document (HTML generated by dkramer on April 22, 1996)
Copyright © 1996 Sun Microsystems, Inc. All rights reserved
Please send any comments or corrections to doug.kramer@sun.com