|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectru.zorin.pictfont.PictFont
public class PictFont
The PictFont
repersents custom fonts and font metrics.
Fonts CAN be created by applications.
Class PictFont allows you to use custom fonts in your MIDlet for mobile phone.
Fonts may be proportional, multi-colored or even animated.
You can use several fonts in one MIDlet.
Fonts can be loaded from jar-file or from the net or from Record Store.
Nested Class Summary | |
---|---|
class |
PictFont.RSFilter
Auxiliary class for using as filter in enumerateRecords() |
Field Summary | |
---|---|
static short |
SYM_FIRST
Code for first symbol included in this font |
static short |
SYM_SPACE
Code of space symbol |
static short |
SYM_UNKNOWN
Code of unknown symbol |
Constructor Summary | |
---|---|
PictFont()
Constructor |
Method Summary | |
---|---|
int |
charsWidth(char[] ch,
int offset,
int length)
Returns the advance width of the characters in ch, starting at the specified offset and for the specified number of characters (length). |
int |
charWidth(char ch)
Gets the advance width of the specified character in this Font. |
void |
drawChar(javax.microedition.lcdui.Graphics g,
char character,
int x,
int y,
int anchor)
Draws the specified character using this PictFont. |
void |
drawChars(javax.microedition.lcdui.Graphics g,
char[] data,
int offset,
int length,
int x,
int y,
int anchor)
Draws the specified characters using this PictFont. |
int |
drawCode(javax.microedition.lcdui.Graphics g,
short code,
int x,
int y)
Draws character with specified code using anchor=LEFT|TOP. |
int |
drawCode(javax.microedition.lcdui.Graphics g,
short code,
int x,
int y,
int anchor)
Draws character with specified code. |
int |
drawCodes(javax.microedition.lcdui.Graphics g,
short[] codes,
int x,
int y)
Draws characters with specified codes using anchor=LEFT|TOP. |
int |
drawCodes(javax.microedition.lcdui.Graphics g,
short[] codes,
int x,
int y,
int anchor)
Draws characters with specified codes. |
void |
drawString(javax.microedition.lcdui.Graphics g,
java.lang.String str,
int x,
int y,
int anchor)
Draws the specified String using the this PictFont. |
void |
drawSubstring(javax.microedition.lcdui.Graphics g,
java.lang.String str,
int offset,
int len,
int x,
int y,
int anchor)
Draws the specified String using the current font and color. |
int |
getBaselinePosition()
Gets the distance in pixels from the top of the text to the text's baseline. |
short |
getCode(char ch)
Gets intrernal code of character. |
short[] |
getCodes(java.lang.String str)
Gets short array with internal codes of all characters of the string. |
int |
getFace()
Gets the face of the font. |
int |
getHeight()
Gets the standard height of a line of text in this font. |
int |
getLeading()
Gets the leading in pixels. |
int |
getLetterSpacing()
Gets the distance in pixels between two letters. |
int |
getMidline()
Gets the distance in pixels from the top of the text to the text's midline. |
int |
getSet()
Gets number of currently used set of symbols. |
int |
getSize()
Gets the size of the font. |
int |
getStyle()
Gets the style of the font. |
int |
getWidth(short code)
Gets actual width of character with specified code . |
int |
getWidth(short[] codes)
Gets actual width of character string with specified codes . |
boolean |
isBold()
Returns true if the font is bold. |
boolean |
isItalic()
Returns true if the font is italic. |
boolean |
isPlain()
Returns true if the font is plain. |
boolean |
isUnderlined()
Returns true if the font is underlined. |
int |
loadFromBinaryResource(java.lang.String info_name,
java.lang.String image_name)
Loads font data from files stored in midlet jar. |
int |
loadFromResource(java.lang.String info_name,
java.lang.String image_name)
Loads font data from files stored in midlet jar. |
int |
loadFromStore(java.lang.String name)
Load font data from Record Store. |
int |
recolor(int color)
Recolor pixels of mainColor with new color. |
int |
saveToStore(java.lang.String name)
Save font data to Record Store. |
int |
setSet(int set)
Defines set of symbol for using. |
int |
stringWidth(java.lang.String str)
Gets the total advance width for showing the specified String in this Font. |
int |
substringWidth(java.lang.String str,
int offset,
int len)
Gets the total advance width for showing the specified substring in this Font. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final short SYM_UNKNOWN
public static final short SYM_SPACE
public static final short SYM_FIRST
Constructor Detail |
---|
public PictFont()
Method Detail |
---|
public int loadFromResource(java.lang.String info_name, java.lang.String image_name)
info_name
- file name of descriptionimage_name
- file name of image
public int saveToStore(java.lang.String name)
name
- name used for identification font in Record Store
public int loadFromStore(java.lang.String name)
name
- name used for identification font in Record Store
public int loadFromBinaryResource(java.lang.String info_name, java.lang.String image_name)
info_name
- file name of descriptionimage_name
- file name of image
public int getStyle()
Font.getStyle()
public int getSize()
Font.getSize()
public int getFace()
Font.getFace()
public boolean isPlain()
Font.isPlain()
public boolean isBold()
Font.isBold()
public boolean isItalic()
Font.isItalic()
public boolean isUnderlined()
Font.isUnderlined()
public int getHeight()
Font.getHeight()
public int getBaselinePosition()
Font.getBaselinePosition()
public int getMidline()
public int getLeading()
public int getLetterSpacing()
public int recolor(int color)
color
- new color
public int charWidth(char ch)
ch
were to be drawn using this Font,
including inter-character spacing following ch
necessary for proper positioning of subsequent text.
ch
- the character to be measured
Font.charWidth(char)
public int charsWidth(char[] ch, int offset, int length)
The offset and length parameters must specify a valid range of characters within the character array ch. The offset parameter must be within the range [0..(ch.length)], inclusive. The length parameter must be a non-negative integer such that (offset + length) <= ch.length.
ch
- the array of charactersoffset
- the index of the first character to measurelength
- the number of characters to measure
java.lang.ArrayIndexOutOfBoundsException
- if offset and length specify an invalid range
java.lang.NullPointerException
- - if ch is nullFont.charsWidth(char[], int, int)
public int stringWidth(java.lang.String str)
str
- the String to be measured
java.lang.NullPointerException
- - if str is nullFont.stringWidth(java.lang.String)
public int substringWidth(java.lang.String str, int offset, int len)
The offset and len parameters must specify a valid range of characters within str. The offset parameter must be within the range [0..(str.length())], inclusive. The len parameter must be a non-negative integer such that (offset + len) <= str.length().
str
- the String to be measuredoffset
- zero-based index of first character in the substringlen
- length of the substring
java.lang.StringIndexOutOfBoundsException
- if offset and length specify an invalid range
java.lang.NullPointerException
- if str is nullFont.substringWidth(java.lang.String, int, int)
public void drawChar(javax.microedition.lcdui.Graphics g, char character, int x, int y, int anchor)
g
- the Graphics object to be used for drawingcharacter
- the character to be drawnx
- the x coordinate of the anchor pointy
- the y coordinate of the anchor pointanchor
- the anchor point for positioning the text;
java.lang.IllegalArgumentException
- if anchor is not a legal valueGraphics.drawChar(char, int, int, int)
public void drawChars(javax.microedition.lcdui.Graphics g, char[] data, int offset, int length, int x, int y, int anchor)
The offset and length parameters must specify a valid range of characters within the character array data. The offset parameter must be within the range [0..(data.length)], inclusive. The length parameter must be a non-negative integer such that (offset + length) <= data.length.
g
- the Graphics object to be used for drawingdata
- the array of characters to be drawnoffset
- the array of characters to be drawnlength
- the number of characters to be drawnx
- the x coordinate of the anchor pointy
- the y coordinate of the anchor pointanchor
- the anchor point for positioning the text
java.lang.ArrayIndexOutOfBoundsException
- if offset and length do not specify a valid
range within the data array
java.lang.IllegalArgumentException
- if anchor is not a legal value
java.lang.NullPointerException
- if data is nullGraphics.drawChars(char[], int, int, int, int, int)
public void drawString(javax.microedition.lcdui.Graphics g, java.lang.String str, int x, int y, int anchor)
g
- the Graphics object to be used for drawingstr
- the String to be drawnx
- the x coordinate of the anchor pointy
- the y coordinate of the anchor pointanchor
- the anchor point for positioning the textGraphics.drawString(java.lang.String, int, int, int)
public void drawSubstring(javax.microedition.lcdui.Graphics g, java.lang.String str, int offset, int len, int x, int y, int anchor)
The offset and len parameters must specify a valid range of characters within the string str. The offset parameter must be within the range [0..(str.length())], inclusive. The len parameter must be a non-negative integer such that (offset + len) <= str.length().
g
- the Graphics object to be used for drawingstr
- the String to be drawnoffset
- zero-based index of first character in the substringlen
- length of the substringx
- the x coordinate of the anchor pointy
- the y coordinate of the anchor pointanchor
- the anchor point for positioning the textGraphics.drawSubstring(java.lang.String, int, int, int, int, int)
public int getSet()
public int setSet(int set)
set
- new set
public short getCode(char ch)
SYM_UNKNOWN
if character is not found in this PictFont
.
ch
- character
public short[] getCodes(java.lang.String str)
str
- string
public int getWidth(short code)
code
.
This is not advance width of character which used in Font.charWidth(char ch).
Actual width does not include inter-character space.
code
-
code
public int getWidth(short[] codes)
codes
.
This is not advance width of character which used in Font.charWidth(char ch).
Actual width does not include inter-character space.
codes
- array of character codes
codes
public int drawCode(javax.microedition.lcdui.Graphics g, short code, int x, int y)
g
- Graphicscode
- code of characterx
- the x coordinate of top left cornery
- the y coordinate of top left corner
public int drawCode(javax.microedition.lcdui.Graphics g, short code, int x, int y, int anchor)
g
- Graphicscode
- code of characterx
- the x coordinate of top left cornery
- the y coordinate of top left corner
public int drawCodes(javax.microedition.lcdui.Graphics g, short[] codes, int x, int y)
g
- Graphics objectcodes
- array of character codesx
- the x coordinate of top left cornery
- the y coordinate of top left corner
public int drawCodes(javax.microedition.lcdui.Graphics g, short[] codes, int x, int y, int anchor)
g
- Graphicscodes
- code array with string of charactersx
- the x coordinate of top left cornery
- the y coordinate of top left corner
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |