com.flagstone.transform.font
Class Kerning

java.lang.Object
  extended by com.flagstone.transform.font.Kerning
All Implemented Interfaces:
SWFEncodeable

public final class Kerning
extends Object
implements SWFEncodeable

Kerning is used to fine-tune the spacing between specific pairs of characters to make them visually more appealing.

The glyphs are identified by an index into the glyph table for the font. The adjustment, in twips, is specified relative to the advance define for the left hand glyph.

Kerning objects are only used within DefineFont2 objects and provide more precise control over the layout of a font's glyph than was possible using the DefineFont and FontInfo objects.

See Also:
DefineFont2

Constructor Summary
Kerning(int leftIndex, int rightIndex, int adjust)
          Creates a Kerning object specifying the glyph indexes and adjustment.
Kerning(SWFDecoder coder, Context context)
          Creates and initialises a Kerning object using values encoded in the Flash binary format.
 
Method Summary
 void encode(SWFEncoder coder, Context context)
          Encode an object to the Flash binary format.
 boolean equals(Object object)
           
 int getAdjustment()
          Get the adjustment, in twips, to the advance of the left glyph.
 int getLeftGlyph()
          Get the index of the left glyph in the kerning pair.
 int getRightGlyph()
          Get the index of the right glyph in the kerning pair.
 int hashCode()
           
 int prepareToEncode(Context context)
          Prepare an object for encoding, returning the expected size of an object when it is encoded.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Kerning

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

Kerning

public Kerning(int leftIndex,
               int rightIndex,
               int adjust)
Creates a Kerning object specifying the glyph indexes and adjustment. The value for the adjustment must be specified in twips.

Parameters:
leftIndex - the index in a code table for the glyph on the left side of the pair. Must be in the range 0..65535.
rightIndex - the index in a code table for the glyph on the right side of the pair. Must be in the range 0..65535.
adjust - the adjustment that will be added to the advance defined for the left glyph. Must be in the range -32768..32767.
Method Detail

getLeftGlyph

public int getLeftGlyph()
Get the index of the left glyph in the kerning pair.

Returns:
the index of the left glyph.

getRightGlyph

public int getRightGlyph()
Get the index of the right glyph in the kerning pair.

Returns:
the index of the right glyph.

getAdjustment

public int getAdjustment()
Get the adjustment, in twips, to the advance of the left glyph.

Returns:
the adjustment to the glyph spacing.

toString

public String toString()
Overrides:
toString in class Object

equals

public boolean equals(Object object)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode 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.