Class FxFont
public class FxFont extends Font
{
// Fields
public static final int ANTIALIAS;
public static final int EMBEDDED;
public static final int ROTATABLE;
public static final int STRIKEOUT;
public static final int UNDERLINE;
// Constructors
public FxFont();
public FxFont(String name, int style, int size);
public FxFont(String name, int style, int size, int flags);
// Methods
public boolean drawBytesCallback(FxGraphics g, byte data[],
int offset, int length, int x, int y,
Rectangle optionRect, int options, int dx[], int dy[]);
public boolean drawCharsCallback(FxGraphics g, char data[],
int offset, int length, int x, int y,
Rectangle optionRect, int options, int dx[], int dy[],
boolean meta);
public boolean drawOutlineCharCallback(FxGraphics g, int xOrig,
int yOrig, GlyphOutline go);
public boolean drawStringCallback(FxGraphics g, String str,
int x, int y, Rectangle optionRect, int options,
int dx[], int dy[]);
public static String[] getAttributeList();
public static String[] getAttributeList(String faceName);
public FxFont getEmboldenedFont();
public int getFlags();
public static int getFlagsVal(String face, String attribute);
public static Font getFont(String face, Vector v, int size);
public static Font getFont(String face, int style, int size,
int flags);
public static String[] getFontList();
public FontMetrics getFontMetricsCallback(FxGraphics g);
public GlyphOutline getGlyphOutlineCallback(FxGraphics g,
char ch);
public static int getStyleVal(String face, String attribute);
public void setBackgroundCallback(Color c);
public void setColorCallback(Color c);
public void setFontCallback(FxGraphics g);
}
This class produces user-defined font objects.
The FxFont class is one of several extensible classes that are included in the com.ms.fx package. FxFont objects can be used for font objects that are selected into an extended graphics context in the same way that FxTexture and FxPen are used for color objects.
The FxFont class provides methods that you can construct custom fonts with and a base that you can derive new font classes from (for example, FxOutlineFont).
Note The callback methods in this documentation are only used internally and are not meant to be called directly. They are included so that font-derived classes can extend the callback functionality. For more information on callback methods, see the com.ms.fx package overview information.
Font
|
+--FxFont
public FxFont();
Constructs a generic font. This is the constructor used by JavaBeans objects.
public FxFont(String name, int style, int size);
Constructs an FxFont object.
Parameter | Description |
name
| The name of the font.
|
style
| The style of the font. This may be either BOLD, ITALIC, or PLAIN.
|
size
| The size of the font, measured in points.
|
public FxFont(String name, int style, int size, int flags);
Constructs an FxFont object with specified flags.
Parameter | Description |
name
| The name of the font.
|
style
| The style of the font. This may be either BOLD, ITALIC, or PLAIN.
|
size
| The size of the font, measured in points.
|
flags
| The font flags, which can be either STRIKEOUT, UNDERLINE, or EMBEDDED.
|
public boolean drawBytesCallback(FxGraphics g, byte data[], int offset, int
length, int x, int y, Rectangle optionRect, int options, int dx[],
int dy[]);
Draws an array of bytes when called by an FxGraphics object.
Note This method is called by FxGraphics if drawBytes is called and an FxFont object is the selected font. The callback methods are used internally and are not intended to be called by applications. It is made public so that derived classes can extend the callback functionality.
Return Value:
Returns true if successful; otherwise, returns false.
Parameter | Description |
g
| The graphic object used.
|
data
| The array of bytes that is drawn.
|
offset
| The offset used.
|
length
| The length of the array used.
|
x
| The x coordinate of the location where the bytes are drawn.
|
y
| The y coordinate of the location where the bytes are drawn.
|
optionRect
| The optional rectangle used for clipping or opaquing.
|
options
| This may be CHAR_OPAQUE, CHAR_CLIP, or CHAR_KERNING (not implemented).
|
dx
| The array of dx values.
|
dy
| The array of dy values.
|
See Also: com.ms.fx.FxGraphics.drawBytes
public boolean drawCharsCallback(FxGraphics g, char data[], int offset, int
length, int x, int y, Rectangle optionRect, int options, int dx[],
int dy[], boolean meta);
Draws an array of characters when called by an FxGraphics object.
Note This method is called by FxGraphics if drawChars is called and if an FxFont object is the selected font.
The callback methods are used internally and are not intended to be called by applications. It is made public so that derived classes can extend the callback functionality.
Return Value:
Returns true if successful; otherwise, returns false.
Parameter | Description |
g
| The graphics object.
|
data
| The array of characters that is drawn.
|
offset
| The offset that is used.
|
length
| The length of the array used.
|
x
| The x coordinate of the location where the characters are drawn.
|
y
| The y coordinate of the location where the characters are drawn.
|
optionRect
| The optional rectangle used for clipping or opaquing.
|
options
| This may be CHAR_OPAQUE, CHAR_CLIP, or CHAR_KERNING (not implemented).
|
dx
| The array of dx values.
|
dy
| The array of dy values.
|
meta
| |
See Also: com.ms.fx.FxGraphics.drawChars
public boolean drawOutlineCharCallback(FxGraphics g, int xOrig, int yOrig,
GlyphOutline go);
Draws an outline character when called by an FxGraphics object.
Note This method is called by FxGraphics to draw an outline character and an FxFont object is the selected font. The callback methods are used internally and are not intended to be called by applications. It is made public so that derived classes can extend the callback functionality.
Return Value:
Returns true if successful; otherwise, returns false.
Parameter | Description |
g
| The graphic object used.
|
xOrig
| The x coordinate of the character.
|
yOrig
| The y coordinate of the character.
|
go
| The GlyphOutline that is used.
|
public boolean drawStringCallback(FxGraphics g, String str, int x, int y,
Rectangle optionRect, int options, int dx[], int dy[]);
Draws a string when this method is called by an FxGraphics object.
Note This method is called by FxGraphics if drawString is called and an FxFont object is the selected font. The callback methods are used internally and are not intended to be called by applications. It is made public so that derived classes can extend the callback functionality.
Return Value:
Returns true if successful; otherwise, returns false
Parameter | Description |
g
| The graphic object used.
|
str
| The string that is drawn.
|
x
| The x coordinate of the location where the string is drawn.
|
y
| The y coordinate of the location where the string is drawn.
|
optionRect
| The optional rectangle used for clipping or opaquing.
|
options
| The options set for the method.
|
dx
| The array of dx values.
|
dy
| The array of dy values.
|
See Also: com.ms.fx.FxGraphics.drawString
public static String[] getAttributeList();
Retrieves a list of the generic attributes that the font supports.
Return Value:
Returns the list of attributes that the font supports.
public static String[] getAttributeList(String faceName);
Retrieves a list of the attributes that the font supports.
Return Value:
Returns the font attributes include the following:
"Bold"
|
"Italic"
|
"Underline"
|
"Strikeout"
|
"Anti-Aliased"
|
"Rotatable"
|
Parameter | Description |
faceName
| The name of the font.
|
public FxFont getEmboldenedFont();
Retrieves a bold version of the current font. Typically, a bold font is used in default titles, default buttons on a UIButtonBar, and other emphasized text.
Return Value:
Returns a bold version of the current font. If the font is already bold, the method returns without performing an operation.
public int getFlags();
Retrieves any extra flags set for the FxFont object.
Return Value:
Returns the flags that are currently set.
public static int getFlagsVal(String face, String attribute);
Retrieves a value for the flags of the given face name.
Return Value:
Returns a value for the flags.
Parameter | Description |
face
| The name of the font.
|
attribute
| A string that contains the attributes (for example, "Rotatable") of the font.
|
public static Font getFont(String face, Vector v, int size);
Retrieves a font if an exact match is made, given the face, vector, and size.
Return Value:
Returns a Font object that matches the given parameters.
Parameter | Description |
face
| The font's face name ("Helvetica", for example).
|
v
| A list of style names.
|
size
| The size of the font, in points.
|
public static Font getFont(String face, int style, int size, int flags);
Retrieves a font if an exact match is made, given the face, style, size, and flags.
Return Value:
Returns a Font object that matches the given parameters.
Parameter | Description |
face
| The font's face name ("Helvetica", for example).
|
style
| The font's style.
|
size
| The size of the font, in points.
|
flags
| Can be one or a combination of the following: EMBEDDED, STRIKEOUT, or UNDERLINE.
|
public static String[] getFontList();
Retrieves a list of the faces that the font supports.
Return Value:
Returns the list of faces as an array of String objects.
public FontMetrics getFontMetricsCallback(FxGraphics g);
Retrieves the font metrics when called by an FxGraphics object.
Note This method is called by FxGraphics if getFontMetrics is called when an FxFont object is the selected font. The object returned must be derived from the FontMetrics class. The callback methods are used internally and are not intended to be called by applications. It is made public so that derived classes can extend the callback functionality.
Return Value:
Returns the FontMetrics of the font
Parameter | Description |
g
| The graphic object used.
|
See Also: java.awt.Graphics.getFontMetrics
public GlyphOutline getGlyphOutlineCallback(FxGraphics g, char ch);
Retrieves a glyph outline for the character.
Return Value:
Returns a character glyph outline.
Parameter | Description |
g
| The graphic object used.
|
ch
| The character that the glyph outline is found for.
|
public static int getStyleVal(String face, String attribute);
Retrieves a value for the style flags of the given face name.
Return Value:
Returns a value for the font's style flags.
Parameter | Description |
face
| The name of the font.
|
attribute
| A string that contains the attributes (for example, "Rotatable") of the font.
|
public void setBackgroundCallback(Color c);
Sets the text background color when called by an FxGraphics object.
Note This method is called by FxGraphics if setTextBackgroundColor is called and an FxFont object is the selected font. The callback methods are used internally and are not intended to be called by applications. It is made public so that derived classes can extend the callback functionality. Currently, this method is not implemented.
Return Value:
No return value.
Parameter | Description |
c
| The background color.
|
See Also: com.ms.fx.FxGraphics.setTextBackground
public void setColorCallback(Color c);
Sets the foreground color of the font when called by an FxGraphics object.
Note This method is called by FxGraphics if setColor is called and an FxFont object is the selected font. The callback methods are used internally and are not intended to be called by applications. It is made public so that derived classes can extend the callback functionality.
Return Value:
No return value.
Parameter | Description |
c
| The foreground color.
|
See Also: com.ms.fx.FxGraphics.setColor
public void setFontCallback(FxGraphics g);
Sets the font used by the extended graphics context when called by an FxGraphics object.
Note This method is called by FxGraphics if setFont is called when an FxFont object is the selected font. The method selects the current font for use as the native graphics font object. This approach enables the object to do any device-specific operation. The default action is to pass the font back and use it as a native font. The callback methods are used internally and are not intended to be called by applications. It is made public so that derived classes can extend the callback functionality.
Return Value:
No return value.
Parameter | Description |
g
| The graphic object used.
|
See Also: com.ms.fx.FxGraphics.setFont
- ANTIALIAS
- Indicates the font object is anti-aliased. (Anti-aliasing is the smoothing of diagonal lines and curves.)
- EMBEDDED
- Indicates that the new font is linked to a privately-embedded font.
- ROTATABLE
- Indicates that the font object can be rotated.
- STRIKEOUT
- Indicates that the font object is struck out.
- UNDERLINE
- Indicates that the font object is underlined.