|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.flagstone.transform.util.font.Font
public final class Font
Font is used to add embedded fonts to a movie.
Flash supports two types of font definition: embedded fonts where the Flash file contains the glyphs that are drawn to represents the text characters and device fonts where the font is provided by the Flash Player showing the movie. Embedded fonts are preferred since the movie will always look the same regardless of where it is played - if a Flash Player does not contain a device font it will substitute it with another.
Device fonts can be added to a movie by simply creating a DefineFont or DefineFont2 object which contain the name of the font. An embedded font must contain all the information to draw and layout the glyphs representing the text to be displayed. The Font class hides all this detail and makes it easy to add embedded fonts to a movie.
The Font class can be used to create embedded fonts in three ways:
For OpenType or TrueType fonts, files with the extensions ".otf" or ".ttf" may be used. Files containing collections of fonts ".otc" are not currently supported.
Using an existing Flash font definition is the most interesting. Fonts can initially be created using AWT Font objects or TrueType files and all the visible characters included. If the generated Flash definition is saved to a file it can easily and quickly be loaded. Indeed the overhead of parsing an AWT or TrueType font is significant (sometimes several seconds) so creating libraries of "pre-parsed" flash fonts is the preferred way of use fonts.
| Constructor Summary | |
|---|---|
Font()
|
|
| Method Summary | |
|---|---|
void |
addGlyph(char code,
Glyph glyph)
Add a character and the corresponding glyph that is displayed to the font. |
void |
addMissingGlyph(char code)
Add a character to the font where the missing glyph will be displayed. |
int |
advanceForCharacter(char character)
Returns the default advance for the font as defined in the EM Square - conceptually a font with a point size of 1024. |
boolean |
canDisplay(char character)
Tests whether a character can be displayed by the font or whether the "missing" character glyph (usually an empty box) will be displayed instead. |
int |
canDisplay(String aString)
Tests whether the font can display all the characters in a string. |
char |
characterForGlyph(int index)
Returns the characters code for the glyph at a specified index in the font. |
DefineFont2 |
defineFont(int identifier,
List<Character> characters)
Create and return a DefineFont2 object that contains information to display a set of characters. |
int |
getAscent()
Get the ascent for the font in twips. |
int |
getDescent()
Get the descent for the font in twips. |
CharacterFormat |
getEncoding()
Get the encoding scheme used for the character codes, either UCS2, ANSI or SJIS. |
FontFace |
getFace()
Get the FontFace that contains the font name and style. |
Glyph |
getGlyph(int index)
Get the glyph from the specified position in the table. |
char |
getHighestChar()
Get the highest character code defined in the font. |
int |
getLeading()
Returns the leading for the font in twips. |
int |
getMissingGlyph()
Get the index of the glyph used to represent characters that are not supported int the font. |
int |
getNumberOfGlyphs()
Get the number of glyphs defined in the font. |
int |
glyphForCharacter(char character)
Returns the glyph for the specified character. |
void |
setAscent(int dist)
Sets the ascent for the font in twips. |
void |
setDescent(int dist)
Sets the descent for the font in twips. |
void |
setEncoding(CharacterFormat enc)
Set the encoding scheme used for the character codes, either UCS2, ANSI or SJIS. |
void |
setFace(FontFace fontFace)
Set the FontFace that contains the font name and style. |
void |
setHighestChar(char highest)
Set the highest character code defined in the font. |
void |
setLeading(int dist)
Sets the leading for the font in twips. |
void |
setMissingGlyph(int index)
Select the glyph used to represent characters that are not supported int the font. |
void |
setNumberOfGlyphs(int count)
Set the number of glyphs defined in the font. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public Font()
| Method Detail |
|---|
public FontFace getFace()
public void setFace(FontFace fontFace)
fontFace - the FontFace.public CharacterFormat getEncoding()
public void setEncoding(CharacterFormat enc)
enc - the encoding used for the character codes.public int getAscent()
public void setAscent(int dist)
dist - the ascent for the font in the range -32768..32767.public int getDescent()
public void setDescent(int dist)
dist - the descent for the font in the range -32768..32767.public int getLeading()
public void setLeading(int dist)
dist - the descent for the font in the range -32768..32767.public int getNumberOfGlyphs()
public void setNumberOfGlyphs(int count)
count - the number of glyphs.public char getHighestChar()
public void setHighestChar(char highest)
highest - the highest character code.public int getMissingGlyph()
public void setMissingGlyph(int index)
index - the index of the glyph that will be used to display
unsupported characters.public Glyph getGlyph(int index)
index - the index of the glyph.
public void addGlyph(char code,
Glyph glyph)
code - the characterglyph - the glyph displayed for the character.public void addMissingGlyph(char code)
code - the character where there is no corresponding glyph.
public DefineFont2 defineFont(int identifier,
List<Character> characters)
identifier - the unique identifier that will be used to reference the font
definition in the flash file.characters - the set of characters that the font must contain glyphs and
layout information for,
public int canDisplay(String aString)
aString - the string to be displayed.
public boolean canDisplay(char character)
character - the character to be displayed.
public int glyphForCharacter(char character)
character - the character.
public char characterForGlyph(int index)
index - the index of the font.
public int advanceForCharacter(char character)
character - the character code.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||