|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectdanger.ui.Font
public abstract class Font
The Font class provides methods for obtaining fonts, and to query fonts
for their characteristics. Once obtained, the most common use for a font
is to use it in a call to Pen.setFont(danger.ui.Font).
| Nested Class Summary | |
|---|---|
static class |
Font.GlyphMetrics
The metrics of a glyph in this font. |
| Field Summary | |
|---|---|
static int |
F_BOLD
|
static int |
F_CONDENSED
Deprecated. This is no longer used. |
static int |
F_HOLLOW
|
static int |
F_ITALIC
|
static int |
F_MONOSPACE
|
static int |
F_OUTLINE
|
static int |
F_PALETTIZED
|
static int |
F_STRIKETHROUGH
|
static int |
F_UNDERLINE
|
static int |
FLAG_FONT_FAMILIES_ONLY
|
static int |
FLAG_FONT_NAMES_SORTED
|
static char |
GLYPH_ALT
|
static char |
GLYPH_BACK
|
static char |
GLYPH_CANCEL
|
static char |
GLYPH_DELETE
|
static char |
GLYPH_DOWN_ARROW
|
static char |
GLYPH_END_CALL
|
static char |
GLYPH_HIPTOP_LARGE
|
static char |
GLYPH_HIPTOP_SMALL
|
static char |
GLYPH_JUMP
|
static char |
GLYPH_LEFT_ARROW
|
static char |
GLYPH_LEFT_SHOULDER
|
static char |
GLYPH_MENU
|
static char |
GLYPH_PAGE_DOWN
|
static char |
GLYPH_PAGE_UP
|
static char |
GLYPH_POWER
|
static char |
GLYPH_RETURN
|
static char |
GLYPH_RIGHT_ARROW
|
static char |
GLYPH_RIGHT_SHOULDER
|
static char |
GLYPH_SEND_CALL
|
static char |
GLYPH_SHIFT
|
static char |
GLYPH_SHIFT_DE
|
static char |
GLYPH_SHIFT_ES
|
static char |
GLYPH_SHIFT_FR
|
static char |
GLYPH_SIM_LARGE
|
static char |
GLYPH_SIM_SMALL
|
static char |
GLYPH_SLASHED_ZERO
|
static char |
GLYPH_SYM
|
static char |
GLYPH_UP_ARROW
|
static char |
GLYPH_VOLUME_DOWN
|
static char |
GLYPH_VOLUME_UP
|
static char |
GLYPH_WHEEL
|
| Method Summary | |
|---|---|
static void |
addFontsToMenu(Menu fontMenu,
Listener listener)
Add to the provided Menu new items naming well-known fonts available on the device. |
int |
charWidth(int c)
Return the number of pixels by which a Pen would advance horizontally when drawing the specified character in this font. |
static Font |
findBoldFont(String name)
Find the bold font corresponding to the named font. |
static Font |
findBoldItalicFont(String name)
Find the bold-italic font corresponding to the named font. |
static Font |
findBoldItalicSystemFont()
Return the bold-italic variant of the standard system font. |
static Font |
findBoldOutlineSystemFont()
|
static Font |
findBoldSystemFont()
Return the boldface variant of the standard system font. |
static Font |
findFont(String str)
Return the Font with the specified name. |
static Font |
findItalicFont(String name)
Find the italic font corresponding to the named font. |
static Font |
findItalicOutlineSystemFont()
|
static Font |
findItalicSystemFont()
Return the italic variant of the standard system font. |
static Font |
findOutlineSystemFont()
|
static Font |
findSystemFont()
Return the standard system font. |
Font |
findVariant(String newFamily,
int newSize,
int newStyle)
Return a Font that corresponds to this one, modified according to the specified properties. |
int |
getAdvance(byte[] s,
int offset,
int len)
Return the number of pixels by which a Pen would advance horizontally when drawing the characters corresponding to the specified sequence of UTF-8-encoded bytes in this font. |
int |
getAdvance(char[] s,
int offset,
int len)
Return the number of pixels by which a Pen would advance horizontally when drawing the specified sequence of characters in this font. |
int |
getAdvance(CharSequence s)
Return the number of pixels by which a Pen would advance horizontally when drawing the specified sequence of characters in this font. |
int |
getAdvance(CharSequence s,
int offset,
int len)
Return the number of pixels by which a Pen would advance horizontally when drawing the specified subsequence of characters in this font. |
int |
getAscent()
Return the ascent (in pixels) of the tallest character in this font above the baseline. |
int |
getDescent()
Return the descent (in pixels) of the character in this font that extends the furthest below the baseline. |
abstract String |
getFamily()
Return the family of this font ("bort", "twig", or whatever) |
int |
getFitLtoR(CharSequence s,
int start_index,
int max_width)
Return the number of characters from the specified sequence beginning at the specified start_index whose total advance is less than the specified max_width. |
int |
getFitLtoR(String s,
int start_index,
int max_width)
Return the number of characters from the specified sequence beginning at the specified start_index whose total advance is less than the specified max_width. |
int |
getFitRtoL(String s,
int start_index,
int max_width)
Return the number of characters from the specified sequence ending at (not just after) the specified start_index whose total advance is less than the specified max_width. |
static Menu |
getFontMenu(Listener listener)
Return a Menu containing items naming well-known fonts available on the device. |
static String[] |
getFontNames(int flags)
Return a list of the names of all the fonts available on the system. |
int |
getGap()
Deprecated. Use getMetrics(char, danger.ui.Font.GlyphMetrics)
Return the gap (in pixels) between characters in this font.
This may be negative if characters can overlap. This value
is not generally actually very meaningful because often
fonts will require different spacing between different
characters.
This default implementation returns 0,
so subclasses need to do something more sensible. |
boolean |
getMetrics(char c,
Font.GlyphMetrics m)
Fetch the metrics in a fractional 16.16 format of a glyph that would represent the given unicode character. |
abstract String |
getName()
Return the name of this font ("BortBoldItalic9" or whatever) |
abstract int |
getSize()
Return the size of this font (9, 12, etc.) |
abstract int |
getStyle()
Return the style of this font (0, F_BOLD, F_BOLD | F_ITALIC, etc.) |
int |
getWidth(byte[] data,
int offset,
int len)
Return the visual width in pixels of the sequence of characters corresponding to the specified sequence of UTF-8-encoded bytes this Font. |
int |
getWidth(char[] data,
int offset,
int len)
Return the visual width in pixels of the specified sequence of characters in this Font. |
int |
getWidth(CharSequence cs)
Return the visual width in pixels of the specified sequence of characters in this Font. |
int |
getWidth(CharSequence cs,
int offset,
int len)
Return the visual width in pixels of the specified subsequence of characters in this Font. |
int |
getWidth(String s)
Return the visual width in pixels of the specified sequence of characters in this Font. |
int |
getWidth(String s,
int offset,
int len)
Return the visual width in pixels of the specified subsequence of characters in this Font. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final char GLYPH_RETURN
public static final char GLYPH_DELETE
public static final char GLYPH_ALT
public static final char GLYPH_UP_ARROW
public static final char GLYPH_BACK
public static final char GLYPH_JUMP
public static final char GLYPH_MENU
public static final char GLYPH_SLASHED_ZERO
public static final char GLYPH_SHIFT
public static final char GLYPH_WHEEL
public static final char GLYPH_LEFT_ARROW
public static final char GLYPH_RIGHT_ARROW
public static final char GLYPH_DOWN_ARROW
public static final char GLYPH_POWER
public static final char GLYPH_CANCEL
public static final char GLYPH_PAGE_UP
public static final char GLYPH_PAGE_DOWN
public static final char GLYPH_LEFT_SHOULDER
public static final char GLYPH_RIGHT_SHOULDER
public static final char GLYPH_END_CALL
public static final char GLYPH_SEND_CALL
public static final char GLYPH_VOLUME_DOWN
public static final char GLYPH_VOLUME_UP
public static final char GLYPH_HIPTOP_LARGE
public static final char GLYPH_HIPTOP_SMALL
public static final char GLYPH_SIM_LARGE
public static final char GLYPH_SIM_SMALL
public static final char GLYPH_SYM
public static final char GLYPH_SHIFT_FR
public static final char GLYPH_SHIFT_DE
public static final char GLYPH_SHIFT_ES
public static final int FLAG_FONT_NAMES_SORTED
public static final int FLAG_FONT_FAMILIES_ONLY
public static final int F_UNDERLINE
public static final int F_BOLD
public static final int F_ITALIC
public static final int F_OUTLINE
public static final int F_HOLLOW
public static final int F_CONDENSED
public static final int F_PALETTIZED
public static final int F_MONOSPACE
public static final int F_STRIKETHROUGH
| Method Detail |
|---|
public abstract String getName()
public abstract String getFamily()
public abstract int getSize()
public abstract int getStyle()
public static String[] getFontNames(int flags)
public static Menu getFontMenu(Listener listener)
public static void addFontsToMenu(Menu fontMenu,
Listener listener)
public static Font findFont(String str)
public static Font findSystemFont()
public static Font findBoldSystemFont()
public static Font findItalicSystemFont()
public static Font findBoldItalicSystemFont()
public static Font findOutlineSystemFont()
public static Font findItalicOutlineSystemFont()
public static Font findBoldOutlineSystemFont()
public static Font findBoldFont(String name)
name - non-null; the name of the non-bold font
null if there is
nonepublic static Font findItalicFont(String name)
name - non-null; the name of the non-italic font
null if there is
nonepublic static Font findBoldItalicFont(String name)
name - non-null; the name of the non-bold non-italic font
null if there
is none
public Font findVariant(String newFamily,
int newSize,
int newStyle)
newFamily - if non-null, the name of the font family
("bort", "twig", etc.)newSize - if not -1, the desired size of the font (9, 12, etc.)newStyle - if not 0, the style properties to add to the
font (F_BOLD, F_ITALIC, etc.)public int charWidth(int c)
public int getAdvance(CharSequence s)
charWidth(int) of the individual
characters in the sequence, but may change in the future
when we have kerning and fractional pixel spacing.
If your CharSequence may be Spanned,
you probably want
CharacterSpan.Series.getAdvance(danger.ui.Font, java.lang.CharSequence)
instead, which takes font changes, etc., into account.
public int getWidth(String s)
getAdvance(java.lang.CharSequence) but may be
slightly larger in fonts where some characters extend further
to the right than they advance the pen.
public int getWidth(CharSequence cs)
getAdvance(java.lang.CharSequence) but may be
slightly larger in fonts where some characters extend further
to the right than they advance the pen.
If your CharSequence may be Spanned,
you probably want
CharacterSpan.Series.getWidth(danger.ui.Font, java.lang.CharSequence)
instead, which takes font changes, etc., into account.
public int getAdvance(CharSequence s,
int offset,
int len)
charWidth(int) of the individual
characters in the sequence, but may change in the future
when we have kerning and fractional pixel spacing.
If your CharSequence may be Spanned,
you probably want
CharacterSpan.Series.getAdvance(danger.ui.Font, java.lang.CharSequence)
instead, which takes font changes, etc., into account.
public int getWidth(String s,
int offset,
int len)
getAdvance(java.lang.CharSequence) but may be
slightly larger in fonts where some characters extend further
to the right than they advance the pen.
public int getWidth(CharSequence cs,
int offset,
int len)
getAdvance(java.lang.CharSequence) but may be
slightly larger in fonts where some characters extend further
to the right than they advance the pen.
If your CharSequence may be Spanned,
you probably want
CharacterSpan.Series.getWidth(danger.ui.Font, java.lang.CharSequence)
instead, which takes font changes, etc., into account.
public int getAdvance(byte[] s,
int offset,
int len)
charWidth(int) of the individual
characters in the sequence, but may change in the future
when we have kerning and fractional pixel spacing.
public int getWidth(byte[] data,
int offset,
int len)
getAdvance(java.lang.CharSequence) but may be
slightly larger in fonts where some characters extend further
to the right than they advance the pen.
public int getAdvance(char[] s,
int offset,
int len)
charWidth(int) of the individual
characters in the sequence, but may change in the future
when we have kerning and fractional pixel spacing.
public int getWidth(char[] data,
int offset,
int len)
getAdvance(java.lang.CharSequence) but may be
slightly larger in fonts where some characters extend further
to the right than they advance the pen.
public int getFitLtoR(String s,
int start_index,
int max_width)
public int getFitLtoR(CharSequence s,
int start_index,
int max_width)
public int getFitRtoL(String s,
int start_index,
int max_width)
public int getAscent()
public int getDescent()
public boolean getMetrics(char c,
Font.GlyphMetrics m)
c - The character code to fetch glyph metrics for.m - The structure to fill in with the metrics
public int getGap()
getMetrics(char, danger.ui.Font.GlyphMetrics)
Return the gap (in pixels) between characters in this font.
This may be negative if characters can overlap. This value
is not generally actually very meaningful because often
fonts will require different spacing between different
characters.
This default implementation returns 0,
so subclasses need to do something more sensible.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||