public class Font extends Object
Modifier and Type | Field and Description |
---|---|
static FontTriplet |
DEFAULT_FONT
Default fallback key
|
static int |
PRIORITY_DEFAULT
Default selection priority
|
static String |
STYLE_INCLINED
Inclined font style
|
static String |
STYLE_ITALIC
Italic font style
|
static String |
STYLE_NORMAL
Normal font style
|
static String |
STYLE_OBLIQUE
Oblique font style
|
static int |
WEIGHT_BOLD
Bold font weight
|
static int |
WEIGHT_EXTRA_BOLD
Extra Bold font weight
|
static int |
WEIGHT_LIGHT
Light font weight
|
static int |
WEIGHT_NORMAL
Normal font weight
|
Constructor and Description |
---|
Font(String key,
FontTriplet triplet,
FontMetrics met,
int fontSize)
Main constructor
|
Modifier and Type | Method and Description |
---|---|
int |
getAscender()
Returns the font's ascender.
|
int |
getCapHeight()
Returns the font's CapHeight.
|
int |
getCharWidth(char c)
Helper method for getting the width of a unicode char
from the current fontstate.
|
int |
getDescender()
Returns the font's Descender.
|
FontMetrics |
getFontMetrics()
Returns the associated font metrics object.
|
String |
getFontName()
Returns the font's name.
|
int |
getFontSize()
Returns the font size
|
FontTriplet |
getFontTriplet() |
Map |
getKerning()
Returns the font's kerning table
|
int |
getKernValue(char ch1,
char ch2)
Returns the amount of kerning between two characters.
|
int |
getWidth(int charnum)
Returns the width of a character
|
int |
getWordWidth(String word)
Calculates the word width.
|
int |
getXHeight()
Returns the XHeight
|
boolean |
hasChar(char c)
Determines whether this font contains a particular character/glyph.
|
boolean |
hasKerning() |
char |
mapChar(char c)
Map a java character (unicode) to a font character.
|
String |
toString() |
public static final int WEIGHT_EXTRA_BOLD
public static final int WEIGHT_BOLD
public static final int WEIGHT_NORMAL
public static final int WEIGHT_LIGHT
public static final String STYLE_NORMAL
public static final String STYLE_ITALIC
public static final String STYLE_OBLIQUE
public static final String STYLE_INCLINED
public static final int PRIORITY_DEFAULT
public static final FontTriplet DEFAULT_FONT
public Font(String key, FontTriplet triplet, FontMetrics met, int fontSize)
key
- key of the fonttriplet
- the font triplet that was used to lookup this font (may be null)met
- font metricsfontSize
- font sizepublic FontMetrics getFontMetrics()
public int getAscender()
public int getCapHeight()
public int getDescender()
public String getFontName()
public FontTriplet getFontTriplet()
public int getFontSize()
public int getXHeight()
public boolean hasKerning()
public Map getKerning()
public int getKernValue(char ch1, char ch2)
ch1
- first characterch2
- second characterpublic int getWidth(int charnum)
charnum
- character to look uppublic char mapChar(char c)
c
- character to mappublic boolean hasChar(char c)
c
- character to checkpublic int getCharWidth(char c)
c
- character to inspectpublic int getWordWidth(String word)
word
- text to get width forCopyright © 2007-2019. All Rights Reserved.