com.flagstone.transform.font
Class DefineFont

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

public final class DefineFont
extends Object
implements DefineTag

DefineFont defines the glyphs that are drawn when text characters are rendered in a particular font.

A complete definition of a font is created using the DefineFont object for the glyphs along with an FontInfo or FontInfo2 object which contains the name of the font, whether the font face is bold or italics and a table that maps character codes to the glyphs that is drawn to represent the character.

See Also:
FontInfo, FontInfo2

Constructor Summary
DefineFont(DefineFont object)
          Creates and initialises a DefineFont object using the values copied from another DefineFont object.
DefineFont(int uid, List<Shape> list)
          Creates a DefineFont object setting the unique identifier for the object and the list of glyphs used to render the characters used from the font.
DefineFont(SWFDecoder coder)
          Creates and initialises a DefineFont object using values encoded in the Flash binary format.
 
Method Summary
 DefineFont add(Shape obj)
          Add a shape to the list of shapes that represent the glyphs for the font.
 DefineFont copy()
          Creates a complete copy of this object.
 void encode(SWFEncoder coder, Context context)
          Encode an object to the Flash binary format.
 int getIdentifier()
          Get the unique identifier assigned to this object.
 List<Shape> getShapes()
          Get the list of shapes that define the outline for each glyph.
 int prepareToEncode(Context context)
          Prepare an object for encoding, returning the expected size of an object when it is encoded.
 void setIdentifier(int uid)
          Sets the unique identifier for an object within a given Movie.
 void setShapes(List<Shape> list)
          Sets the list of shapes that describe each glyph.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DefineFont

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

Parameters:
coder - an SWFDecoder object that contains the encoded Flash data.
Throws:
IOException - if an error occurs while decoding the data.

DefineFont

public DefineFont(int uid,
                  List<Shape> list)
Creates a DefineFont object setting the unique identifier for the object and the list of glyphs used to render the characters used from the font.

Parameters:
uid - the unique identifier for this object.
list - a list of Shape objects that define the outlines for each glyph in the font.

DefineFont

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

Parameters:
object - a DefineFont 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.

add

public DefineFont add(Shape obj)
Add a shape to the list of shapes that represent the glyphs for the font.

Parameters:
obj - a shape which must not be null.
Returns:
this object.

getShapes

public List<Shape> getShapes()
Get the list of shapes that define the outline for each glyph.

Returns:
the glyphs for this font.

setShapes

public void setShapes(List<Shape> list)
Sets the list of shapes that describe each glyph.

Parameters:
list - a list of Shape objects that define the outlines for each glyph in the font. Must not be null.

copy

public DefineFont 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.