com.flagstone.transform.font
Class DefineFont2

java.lang.Object
  extended by com.flagstone.transform.font.DefineFont2
All Implemented Interfaces:
Copyable<MovieTag>, SWFEncodeable, DefineTag, MovieTag

public final class DefineFont2
extends Object
implements DefineTag

DefineFont2 defines the shapes and layout of the glyphs used in a font. It extends the functionality provided by DefineFont and FontInfo by:

See Also:
FontInfo, DefineFont

Constructor Summary
DefineFont2(DefineFont2 object)
          Creates and initialises a DefineFont2 object using the values copied from another DefineFont2 object.
DefineFont2(int uid, String fontName)
          Creates a DefineFont2 object specifying only the name of the font.
DefineFont2(SWFDecoder coder, Context context)
          Creates and initialises a DefineFont2 object using values encoded in the Flash binary format.
 
Method Summary
 DefineFont2 add(Bounds rect)
          Add a bounds object to the list of bounds for each glyph.
 DefineFont2 add(Kerning anObject)
          Add a kerning object to the list of kernings for pairs of glyphs.
 DefineFont2 addAdvance(int anAdvance)
          Add an advance to the list of advances.
 DefineFont2 addGlyph(int code, Shape obj)
          Add a character code and the corresponding glyph that will be displayed.
 DefineFont2 copy()
          Creates a complete copy of this object.
 void encode(SWFEncoder coder, Context context)
          Encode an object to the Flash binary format.
 List<Integer> getAdvances()
          Returns the list of advances defined for each glyph in the font.
 int getAscent()
          Get the ascent for the font in twips.
 List<Bounds> getBounds()
          Returns the list of bounding rectangles defined for each glyph in the font.
 List<Integer> getCodes()
          Returns the list of codes used to identify each glyph in the font.
 int getDescent()
          Get the descent for the font in twips.
 CharacterFormat getEncoding()
          Get the encoding scheme used for characters rendered in the font, either ASCII, SJIS or UCS2.
 int getIdentifier()
          Get the unique identifier assigned to this object.
 List<Kerning> getKernings()
          Returns the list of kerning records that define the spacing between glyph pairs.
 Language getLanguage()
          Returns the language code identifying the type of spoken language for the font.
 int getLeading()
          Returns the leading for the font in twips.
 String getName()
          Returns the name of the font family.
 List<Shape> getShapes()
          Returns the list of shapes used to define the outlines of each font glyph.
 boolean isBold()
          Is the font bold.
 boolean isItalic()
          Is the font italicised.
 boolean isSmall()
          Does the font have a small point size.
 int prepareToEncode(Context context)
          Prepare an object for encoding, returning the expected size of an object when it is encoded.
 void setAdvances(List<Integer> list)
          Sets the list of advances for each glyph in the font.
 void setAscent(int aNumber)
          Sets the ascent for the font in twips.
 void setBold(boolean aBool)
          Set the font is bold.
 void setBounds(List<Bounds> list)
          Sets the list of bounding rectangles for each glyph in the font.
 void setCodes(List<Integer> list)
          Sets the codes used to identify each glyph in the font.
 void setDescent(int aNumber)
          Sets the descent for the font in twips.
 void setEncoding(CharacterFormat anEncoding)
          Sets the font character encoding.
 void setIdentifier(int uid)
          Sets the unique identifier for an object within a given Movie.
 void setItalic(boolean aBool)
          Set the font is italicised.
 void setKernings(List<Kerning> list)
          Sets the list of kerning records for pairs of glyphs in the font.
 void setLanguage(Language lang)
          Sets the language code used to determine the position of line-breaks in text rendered using the font.
 void setLeading(int aNumber)
          Sets the leading for the font in twips.
 void setName(String aString)
          Set the name of the font.
 void setShapes(List<Shape> list)
          Set the list of shape records that define the outlines of the characters used from the font.
 void setSmall(boolean aBool)
          Sets the font is small.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DefineFont2

public DefineFont2(SWFDecoder coder,
                   Context context)
            throws IOException
Creates and initialises a DefineFont2 object using values encoded in the Flash binary format.

Parameters:
coder - an SWFDecoder object that contains the encoded Flash data.
context - a Context object used to manage the decoders for different type of object and to pass information on how objects are decoded.
Throws:
IOException - if an error occurs while decoding the data.

DefineFont2

public DefineFont2(int uid,
                   String fontName)
Creates a DefineFont2 object specifying only the name of the font. If none of the remaining attributes are set the Flash Player will load the font from the system on which it is running or substitute a suitable font if the specified font cannot be found. This is particularly useful when defining fonts that will be used to display text in DefineTextField objects. The font will be defined to use Unicode encoding. The flags which define the font's face will be set to false. The arrays of glyphs which define the shapes and the code which map the character codes to a particular glyph will remain empty since the font is loaded from the system on which it is displayed.

Parameters:
uid - the unique identifier for this font object.
fontName - the name of the font.

DefineFont2

public DefineFont2(DefineFont2 object)
Creates and initialises a DefineFont2 object using the values copied from another DefineFont2 object.

Parameters:
object - a DefineFont2 object from which the values will be copied.
Method Detail

getIdentifier

public int getIdentifier()
Get the unique identifier assigned to this object.

Specified by:
getIdentifier in interface DefineTag
Returns:
the unique identifier used by the Flash Player to reference this definition.

setIdentifier

public void setIdentifier(int uid)
Sets the unique identifier for an object within a given Movie.

Specified by:
setIdentifier in interface DefineTag
Parameters:
uid - a unique identifier for the object. Must be in the range 1..65535.

addGlyph

public DefineFont2 addGlyph(int code,
                            Shape obj)
Add a character code and the corresponding glyph that will be displayed. Character codes should be added to the font in ascending order.

Parameters:
code - the character code. Must be in the range 0..65535.
obj - the shape that represents the glyph displayed for the character code.
Returns:
this object.

addAdvance

public DefineFont2 addAdvance(int anAdvance)
Add an advance to the list of advances. The index position of the entry in the advance list is also used to identify the corresponding glyph and vice-versa.

Parameters:
anAdvance - an advance for a glyph. Must be in the range -32768..32767.
Returns:
this object.

add

public DefineFont2 add(Bounds rect)
Add a bounds object to the list of bounds for each glyph. The index position of the entry in the bounds list is also used to identify the corresponding glyph and vice-versa.

Parameters:
rect - an Bounds. Must not be null.
Returns:
this object.

add

public DefineFont2 add(Kerning anObject)
Add a kerning object to the list of kernings for pairs of glyphs.

Parameters:
anObject - an Kerning. Must not be null.
Returns:
this object.

getEncoding

public CharacterFormat getEncoding()
Get the encoding scheme used for characters rendered in the font, either ASCII, SJIS or UCS2.

Returns:
the encoding used for character codes.

isSmall

public boolean isSmall()
Does the font have a small point size. This is used only with a Unicode font encoding.

Returns:
a boolean indicating whether the font will be aligned on pixel boundaries.

setSmall

public void setSmall(boolean aBool)
Sets the font is small. Used only with Unicode fonts.

Parameters:
aBool - a boolean flag indicating the font will be aligned on pixel boundaries.

isItalic

public boolean isItalic()
Is the font italicised.

Returns:
a boolean indicating whether the font is rendered in italics.

isBold

public boolean isBold()
Is the font bold.

Returns:
a boolean indicating whether the font is rendered in a bold face.

getLanguage

public Language getLanguage()
Returns the language code identifying the type of spoken language for the font.

Returns:
the Language used to determine how line-breaks are inserted into text rendered using the font. Returns NONE if the object was decoded from a movie contains Flash 5 or less.

setLanguage

public void setLanguage(Language lang)
Sets the language code used to determine the position of line-breaks in text rendered using the font. NOTE: The language attribute is ignored if the object is encoded in a Flash 5 movie.

Parameters:
lang - the Language identifying the spoken language for the text rendered using the font.

getName

public String getName()
Returns the name of the font family.

Returns:
the name of the font.

getShapes

public List<Shape> getShapes()
Returns the list of shapes used to define the outlines of each font glyph.

Returns:
a list of Shape objects

getCodes

public List<Integer> getCodes()
Returns the list of codes used to identify each glyph in the font. The ordinal position of each Integer representing a code identifies a particular glyph in the shapes list.

Returns:
a list of Integer objects that contain the character codes for each glyph in the font.

getAscent

public int getAscent()
Get the ascent for the font in twips.

Returns:
the ascent for the font.

getDescent

public int getDescent()
Get the descent for the font in twips.

Returns:
the descent for the font.

getLeading

public int getLeading()
Returns the leading for the font in twips.

Returns:
the leading for the font.

getAdvances

public List<Integer> getAdvances()
Returns the list of advances defined for each glyph in the font.

Returns:
a list of Integers that contain the advance for each glyph in the font.

getBounds

public List<Bounds> getBounds()
Returns the list of bounding rectangles defined for each glyph in the font.

Returns:
a list of Bounds objects.

getKernings

public List<Kerning> getKernings()
Returns the list of kerning records that define the spacing between glyph pairs.

Returns:
a list of Kerning objects that define the spacing adjustment between pairs of glyphs.

setEncoding

public void setEncoding(CharacterFormat anEncoding)
Sets the font character encoding.

Parameters:
anEncoding - the encoding used to identify characters, either ASCII, SJIS or UNICODE.

setItalic

public void setItalic(boolean aBool)
Set the font is italicised.

Parameters:
aBool - a boolean flag indicating whether the font will be rendered in italics

setBold

public void setBold(boolean aBool)
Set the font is bold.

Parameters:
aBool - a boolean flag indicating whether the font will be rendered in bold face.

setName

public void setName(String aString)
Set the name of the font.

Parameters:
aString - the name assigned to the font, identifying the font family. Must not be null.

setShapes

public void setShapes(List<Shape> list)
Set the list of shape records that define the outlines of the characters used from the font.

Parameters:
list - a list of Shape objects that define the glyphs for the font. Must not be null.

setCodes

public void setCodes(List<Integer> list)
Sets the codes used to identify each glyph in the font.

Parameters:
list - sets the code table that maps a particular glyph to a character code. Must not be null.

setAscent

public void setAscent(int aNumber)
Sets the ascent for the font in twips.

Parameters:
aNumber - the ascent for the font in the range -32768..32767.

setDescent

public void setDescent(int aNumber)
Sets the descent for the font in twips.

Parameters:
aNumber - the descent for the font in the range -32768..32767.

setLeading

public void setLeading(int aNumber)
Sets the leading for the font in twips.

Parameters:
aNumber - the descent for the font in the range -32768..32767.

setAdvances

public void setAdvances(List<Integer> list)
Sets the list of advances for each glyph in the font.

Parameters:
list - of Integer objects that define the spacing between glyphs. Must not be null.

setBounds

public void setBounds(List<Bounds> list)
Sets the list of bounding rectangles for each glyph in the font.

Parameters:
list - a list of Bounds objects that define the bounding rectangles that enclose each glyph in the font. Must not be null.

setKernings

public void setKernings(List<Kerning> list)
Sets the list of kerning records for pairs of glyphs in the font.

Parameters:
list - a list of Kerning objects that define an adjustment applied to the spacing between pairs of glyphs. Must not be null.

copy

public DefineFont2 copy()
Creates a complete copy of this object.

Specified by:
copy in interface Copyable<MovieTag>
Returns:
a deep-copy of this object. New instances of mutable objects are copied and immutable instances are shared.

toString

public String toString()
Overrides:
toString in class Object

prepareToEncode

public int prepareToEncode(Context context)
Prepare an object for encoding, returning the expected size of an object when it is encoded. This method also used to initialise variables, such as offsets and flags that will be used when the object is encoded. Generally the method returns the size in bytes, however when called on objects that use bit fields such as shapes the methods will return the size in bits.

Specified by:
prepareToEncode in interface SWFEncodeable
Parameters:
context - an Context that allows information to be passed between objects to control how they are initialised for encoding.
Returns:
the size of the object when it is encoded.

encode

public void encode(SWFEncoder coder,
                   Context context)
            throws IOException
Encode an object to the Flash binary format.

Specified by:
encode in interface SWFEncodeable
Parameters:
coder - an SWFEncoder object.
context - an Context that allows information to be passed between objects to control how they are initialised for encoding.
Throws:
IOException - if an error occurs while encoding the object.


Copyright © 2002-2010 Flagstone Software Ltd.. All Rights Reserved.