Packages
 In this topic

*Constructors

*Methods

*Fields

 

Packages   PreviousThis PackageNext
Package com.ms.awt   Previous This
Package
Next

 


Class FontX

public class FontX extends FxFont
{
  // Fields
  public static final int EMBEDDED;
  public static final int OUTLINE;
  public static final int STRIKEOUT;
  public static final int UNDERLINE;

  // Constructors
  public FontX();
  public FontX(String name, int style, int size);
  public FontX(String name, int style, int size, boolean bEmbed);
  public FontX(String name, int style, int size, int xFlags);

  // Methods
  public static FontX chooseFont(Component c);
  public static FontX chooseFont(Component c, FontX f);
  public boolean equals(Object obj);
  public static String[] getAttributeList();
  public static String[] getAttributeList(String face);
  public int getFlags();
  public static int getFlagsVal(String face, String attribute);
  public static Font getFont(String face, int style, int size,
        int flags);
  public static Font getFont(String face, Vector v, int size);
  public static String[] getFontList();
  public static int getStyleVal(String face, String attribute);
  public boolean isTypeable(int language);
  public static boolean matchFace(String face);
  public String toString();
}

This class creates a font object that defines the font family, font face, style, and size. The FontX class also supports TrueType fonts.

With JDK 1.1, fonts are mapped with a font properties file, and you can obtain different fonts by editing this file. However, the Microsoft implementation does not support this type of font association. You can obtain desired fonts with FontX objects; they are created with Win32 font names.

FxFont
  |
  +--FontX

Constructors

FontX

public FontX();

Creates a nondescript font (12-point Dialog).

FontX

public FontX(String name, int style, int size);

Creates a new font with the specified name, style, and point size. This constructor is used to access system fonts on the Microsoft® Win32® platform not otherwise available in Java (for example, the "symbol" font).

ParameterDescription
name The name of the font face.
style The font style, which can be a combination of the values shown in the following table.
BOLD ITALIC PLAIN
size The point size of the font.

FontX

public FontX(String name, int style, int size, boolean bEmbed);

Creates a new font with the specified name, style, and point size; specifies whether the font is embedded.

ParameterDescription
name The name of the font face.
style The font style, which can be a combination of the values shown in the following table.
BOLD ITALIC PLAIN
size The point size of the font.
bEmbed Set to true if the font is embedded, false otherwise.

FontX

public FontX(String name, int style, int size, int xFlags);

Creates an extended font.

ParameterDescription
name The name of the font face.
style The font style, which can be a combination of the values shown in the following table.
BOLD ITALIC PLAIN
size The point size of the font.
xFlags An extended style, which can be one of the values shown in the following table.
EMBEDDED
UNDERLINE
STRIKEOUT
OUTLINE

Methods

chooseFont

public static FontX chooseFont(Component c);

Note This method is obsolete. It has been replaced by the UIFontDialog class.

Return Value:

Returns a FontX object or null if the user cancelled the dialog box by selecting the Cancel button.

ParameterDescription
c A component that owns the dialog box (and subsequently is blocked until the dialog box is closed).

chooseFont

public static FontX chooseFont(Component c, FontX f);

Note This method is obsolete. It has been replaced by the UIFontDialog class.

Return Value:

Returns a FontX object or null if the user cancelled the dialog box by selecting the Cancel button.

ParameterDescription
c A component that owns the dialog box (and subsequently is blocked until the dialog box is closed).
f The FontX object to use as the default.

equals

public boolean equals(Object obj);

Checks that the argument is not null (is either a Font or a FontX object) and has the same name, same style, and same point size as this FontX object.

Return Value:

Returns true if the objects are equal; otherwise, returns false.

ParameterDescription
obj The object to be compared with the FontX object.

getAttributeList

public static String[] getAttributeList();

Retrieves a list of the attributes that the current font supports.

Return Value:

Returns an array of strings describing the attributes the font supports.

getAttributeList

public static String[] getAttributeList(String face);

Retrieves a list of the attributes this font supports, given the font face.

Return Value:

Returns an array of strings describing the attributes the font supports.

ParameterDescription
face The current font face.

getFlags

public int getFlags();

Retrieves the extended flags of a FontX object.

Return Value:

Returns a one or a combination of these extended styles: EMBEDDED, STRIKEOUT, UNDERLINE, and OUTLINE.

getFlagsVal

public static int getFlagsVal(String face, String attribute);

Retrieves a value for the flags associated with the given face.

Return Value:

Returns a value for the face name flags.

ParameterDescription
face The current font face.
attribute A string that contains the attributes (for example, "Rotatable") of the font.

getFont

public static Font getFont(String face, int style, int size, int flags);

Retrieves a font if an exact match is made, given the font face, style, size, and any specified flags.

Return Value:

Returns the Font that is the exact match to the given parameters.

ParameterDescription
face The font face.
style The font style.
size The font size, in points.
flags One or more of the following font flags:
EMBEDDED
STRIKEOUT
UNDERLINE
OUTLINE

getFont

public static Font getFont(String face, Vector v, int size);

Retrieves a font if an exact match is made, given the font face, vector, and size.

Return Value:

Returns the Font that is the exact match to the given parameters.

ParameterDescription
face The font face.
v A list of style names.
size The font size, in points.

getFontList

public static String[] getFontList();

Retrieves a list of the names of the font faces available.

Return Value:

Returns a string array containing the names of available font faces.

getStyleVal

public static int getStyleVal(String face, String attribute);

Retrieves a value for the style associated with the given face.

Return Value:

Returns a value for the face name style.

ParameterDescription
face The current font face.
attribute A string that contains the attributes of the font (for example, "Rotatable").

isTypeable

public boolean isTypeable(int language);

Checks whether the font can be typed in the given language.

Return Value:

Returns true if the font can be typed; otherwise, returns false.

ParameterDescription
language The identifier of the language to be checked.

matchFace

public static boolean matchFace(String face);

Compares the current font face to the specified face.

Return Value:

Returns true if the current face is the same as the specified face; otherwise, returns false.

ParameterDescription
face The name of the font face to compare to the current font face.

toString

public String toString();

Returns a string that specifies the family, font face, style, and size of the given font.

Return Value:

Returns a string having the following format:

class[family=family-name,name=font-name,style=bold/italic,size=size]

Fields

EMBEDDED
Indicates the new font should be linked to a privately embedded font.

Note This is only significant for fonts that are loaded by non-Java objects. Fonts that are loaded by Java objects are automatically embedded.

OUTLINE
Indicates that the text drawn by using the new font should be drawn by using the outline of the glyph. This is only supported by certain fonts in the system, and only GraphicsX will support this feature. Trying to draw outline fonts using a Win32Graphics object will result in the glyph being drawn normally.
STRIKEOUT
Indicates that text drawn using the new font should be struckthrough.
UNDERLINE
Indicates that text drawn using the new font should be underlined.

upnrm.gif © 1998 Microsoft Corporation. All rights reserved. Terms of use.