public abstract class Font extends Object
Font
class represents a font created from system or from
font file.Modifier and Type | Field and Description |
---|---|
protected String |
name |
protected int |
size |
protected int |
style |
static int |
STYLE_BOLD
bold style
|
static int |
STYLE_ITALIC
italic style
|
static int |
STYLE_PLAIN
plain style
|
Constructor and Description |
---|
Font() |
Modifier and Type | Method and Description |
---|---|
static Font |
createFont(byte[] data,
int offset,
int len,
int size)
Create a user font from font file data with the specified size
|
static Font |
createFont(byte[] data,
int offset,
int len,
int size,
int style)
Create a user font from font file data with the specified size and style
|
static Font |
createFont(String source,
int size)
Create a user font from font file with the specified size
|
static Font |
createFont(String source,
int size,
int style)
Create a user font from font file with the specified size and style
|
static Font |
getDefaultFont()
Returns the system default font
|
static Font |
getFont(int size)
Gets a system font which is best fit for the specified size
|
static Font |
getFont(int size,
int style)
Gets a system font which is best fit for the specified size and style
|
static Font |
getFont(String name,
int size)
Gets a system font which is best fit for the specified name and size
|
static Font |
getFont(String name,
int size,
int style)
Gets a system font which is best fit for the specified name, size and
style
|
String |
getName()
Returns the name of the font
|
int |
getSize()
Returns the size of the font
|
int |
getStyle()
Returns the style of the font
|
Area |
StringArea(String str)
Gets the size of the text if it is to be drawn using the font
|
abstract Area |
StringArea(String str,
int letterSpace,
int lineSpace)
Gets the size of the text if it is to be drawn using the font and with
the specified letter space, line space.
|
public static final int STYLE_PLAIN
public static final int STYLE_BOLD
public static final int STYLE_ITALIC
protected String name
protected int size
protected int style
public static Font getDefaultFont()
public static Font getFont(int size)
size
- font sizepublic static Font getFont(int size, int style)
size
- font sizestyle
- font style. a combination of STYLE_PLAIN
,
STYLE_BOLD
and STYLE_ITALIC
public static Font getFont(String name, int size)
name
- font namesize
- font sizepublic static Font getFont(String name, int size, int style)
name
- font namesize
- font sizestyle
- font style. a combination of STYLE_PLAIN
,
STYLE_BOLD
and STYLE_ITALIC
public static Font createFont(String source, int size) throws IOException
source
- file path of font file in jarsize
- font sizeIOException
public static Font createFont(String source, int size, int style) throws IOException
source
- file path of font file in jarsize
- font sizestyle
- font style. a combination of STYLE_PLAIN
,
STYLE_BOLD
and STYLE_ITALIC
IOException
public static Font createFont(byte[] data, int offset, int len, int size) throws IOException
data
- byte array contains the data of the font fileoffset
- the start offset in the data
len
- the number of bytes of the font filesize
- font sizeIOException
public static Font createFont(byte[] data, int offset, int len, int size, int style) throws IOException
data
- byte array contains the data of the font fileoffset
- the start offset in the data
len
- the number of bytes of the font filesize
- font sizestyle
- font style. a combination of STYLE_PLAIN
,
STYLE_BOLD
and STYLE_ITALIC
IOException
public String getName()
public int getSize()
public int getStyle()
public Area StringArea(String str)
str
- the String
to be measuredpublic abstract Area StringArea(String str, int letterSpace, int lineSpace)
str
- the String
to be measuredletterSpace
- letter space of the textlineSpace
- line space of the text