com.flagstone.transform.font
Class FontAlignment

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

public final class FontAlignment
extends Object
implements MovieTag

FontAlignment provides the alignment information for the glyphs in a font.


Nested Class Summary
static class FontAlignment.StrokeWidth
          StrokeWidth is used to provide hints about the thickness of the line used for rendering glyphs in a font.
 
Constructor Summary
FontAlignment(FontAlignment object)
          Creates and initialises a FontAlignment object using the values copied from another FontAlignment object.
FontAlignment(int uid, FontAlignment.StrokeWidth stroke, List<GlyphAlignment> list)
          Creates a new FontAlignment object for the referenced font along with information on the stroke width used to draw the glyphs and a list of alignment zones for each glyph.
FontAlignment(SWFDecoder coder)
          Creates and initialises a FontAlignment object using values encoded in the Flash binary format.
 
Method Summary
 FontAlignment addZone(GlyphAlignment zone)
          Add the alignment information for a glyph to the list.
 FontAlignment 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 of the font definition that the alignment information is for.
 FontAlignment.StrokeWidth getStrokeWidth()
          Get the StrokeWidth that describes how the glyphs in the font are typically drawn.
 List<GlyphAlignment> getZones()
          Get the alignment information for each glyph in the font.
 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 identifier of the font that this alignment information is for.
 void setStrokeWidth(FontAlignment.StrokeWidth stroke)
          Set the StrokeWidth that describes how the glyphs in the font are typically drawn.
 void setZones(List<GlyphAlignment> list)
          Set the alignment information for each glyph in the font.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FontAlignment

public FontAlignment(SWFDecoder coder)
              throws IOException
Creates and initialises a FontAlignment 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.

FontAlignment

public FontAlignment(int uid,
                     FontAlignment.StrokeWidth stroke,
                     List<GlyphAlignment> list)
Creates a new FontAlignment object for the referenced font along with information on the stroke width used to draw the glyphs and a list of alignment zones for each glyph.

Parameters:
uid - the unique identifier of the font.
stroke - the typical width used when drawing the glyphs.
list - a list of alignment boxes used for rendering the glyphs.

FontAlignment

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

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

getIdentifier

public int getIdentifier()
Get the unique identifier of the font definition that the alignment information is for.

Returns:
the unique identifier of the font.

setIdentifier

public void setIdentifier(int uid)
Sets the identifier of the font that this alignment information is for.

Parameters:
uid - the unique identifier of the DefineFont that contains the glyphs for the font. Must be in the range 1..65535.

getStrokeWidth

public FontAlignment.StrokeWidth getStrokeWidth()
Get the StrokeWidth that describes how the glyphs in the font are typically drawn.

Returns:
a StrokeWidth defining how the font is drawn.

setStrokeWidth

public void setStrokeWidth(FontAlignment.StrokeWidth stroke)
Set the StrokeWidth that describes how the glyphs in the font are typically drawn.

Parameters:
stroke - a StrokeWidth defining how the font is drawn.

getZones

public List<GlyphAlignment> getZones()
Get the alignment information for each glyph in the font.

Returns:
a list of GlyphAliment objects that describe the areas in each glyph which can be snapped to the nearest pixel to improve display quality.

setZones

public void setZones(List<GlyphAlignment> list)
Set the alignment information for each glyph in the font.

Parameters:
list - a list of GlyphAliment objects that describe the areas in each glyph which can be snapped to the nearest pixel to improve display quality.

addZone

public FontAlignment addZone(GlyphAlignment zone)
Add the alignment information for a glyph to the list.

Parameters:
zone - the alignment information for a glyph.
Returns:
this object.

copy

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