com.flagstone.transform
Class FSKerning

java.lang.Object
  extended by com.flagstone.transform.FSTransformObject
      extended by com.flagstone.transform.FSKerning
All Implemented Interfaces:
java.lang.Cloneable

public class FSKerning
extends FSTransformObject

FSKerning describes the spacing between a pair of glyphs.

The 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 is specified relative to the advance define for the left glyph.

Attributes
leftIndex The index into the code table that identifies the glyph on the left side of the pair.
rightIndex The index into a code table that identifies the glyph on the right side of the pair.
adjustment The adjustment in twips that will be added to the advance for the glyph on the left side of the pair to obtain the final spacing between the glyphs.

FSKerning objects are only used within FSDefineFont2 objects and provide more precise control over the layout of a font's glyph than was possible using the FSDefineFont and FSFontInfo objects.

History

FSKerning class represents the KerningRecord from the Macromedia Flash (SWF) File Format Specification. It was introduced in Flash 2.


Constructor Summary
FSKerning(FSCoder coder)
          Construct an FSKerning object, initialising it with values decoded from an encoded object.
FSKerning(FSKerning obj)
          Constructs an FSKerning object by copying values from an existing object.
FSKerning(int leftIndex, int rightIndex, int adjust)
          Constructs an FSKerning object specifying the glyph indexes and adjustment.
 
Method Summary
 void appendDescription(java.lang.StringBuffer buffer, int depth)
          AppendDescription is used to present a string description of the object including all nested objects up to a specified depth.
 void decode(FSCoder coder)
           
 void encode(FSCoder coder)
           
 boolean equals(java.lang.Object anObject)
          Returns true if anObject is equal to this one.
 int getAdjustment()
          Gets the adjustment, in twips, to the advance of the left glyph.
 int getLeftGlyphIndex()
          Gets the index of the left glyph in the kerning pair.
 int getRightGlyphIndex()
          Gets the index of the right glyph in the kerning pair.
 int length(FSCoder coder)
           
 void setAdjustment(int aNumber)
          Sets the adjustment, in twips, to the advance of the left glyph.
 void setLeftGlyphIndex(int anIndex)
          Sets the index of the left glyph in the kerning pair.
 void setRightGlyphIndex(int anIndex)
          Sets the index of the right glyph in the kerning pair.
 
Methods inherited from class com.flagstone.transform.FSTransformObject
clone, name, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FSKerning

public FSKerning(FSCoder coder)
Construct an FSKerning object, initialising it with values decoded from an encoded object.

Parameters:
coder - an FSCoder containing the binary data.

FSKerning

public FSKerning(int leftIndex,
                 int rightIndex,
                 int adjust)
Constructs an FSKerning 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.
rightIndex - the index in a code table for the glyph on the right side of the pair.
adjust - the adjustment that will be added to the advance defined for the left glyph.

FSKerning

public FSKerning(FSKerning obj)
Constructs an FSKerning object by copying values from an existing object.

Parameters:
obj - an FSKerning object.
Method Detail

getLeftGlyphIndex

public int getLeftGlyphIndex()
Gets the index of the left glyph in the kerning pair.

Returns:
the index in a code table for the glyph on the left side of the pair.

getRightGlyphIndex

public int getRightGlyphIndex()
Gets the index of the right glyph in the kerning pair.

Returns:
the index in a code table for the glyph on the right side of the pair.

getAdjustment

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

Returns:
the adjustment that will be added to the advance defined for the left glyph.

setLeftGlyphIndex

public void setLeftGlyphIndex(int anIndex)
Sets the index of the left glyph in the kerning pair.

Parameters:
anIndex - the index in a code table for the glyph on the left side of the pair.

setRightGlyphIndex

public void setRightGlyphIndex(int anIndex)
Sets the index of the right glyph in the kerning pair.

Parameters:
anIndex - the index in a code table for the glyph on the right side of the pair.

setAdjustment

public void setAdjustment(int aNumber)
Sets the adjustment, in twips, to the advance of the left glyph.

Parameters:
aNumber - the adjustment that will be added to the advance defined for the left glyph.

equals

public boolean equals(java.lang.Object anObject)
Returns true if anObject is equal to this one. Objects are considered equal if they would generate identical binary data when they are encoded to a Flash file.

Overrides:
equals in class FSTransformObject
Returns:
true if this object would be identical to anObject when encoded.

appendDescription

public void appendDescription(java.lang.StringBuffer buffer,
                              int depth)
Description copied from class: FSTransformObject
AppendDescription is used to present a string description of the object including all nested objects up to a specified depth. This method provide a more controlled way of creating a string representation of an object since large objects such as font or shape definitions can contain dozens of nested objects. The representation of the object is appended to the StringBuffer, showing the name of the class and values of the attributes it contains. If the object contains any attributes that are objects then the object graph will be traversed up to the specified depth. If objects are nested at a level less than specified depth then the full string representation of the object is displayed. For objects at the specified depth only the name of the class is displayed. Any objects below this depth are not displayed.

Specified by:
appendDescription in class FSTransformObject
Parameters:
buffer - a StringBuffer to which the description of each object is appended.
depth - the maximum level of nesting up to which objects will be displayed.

length

public int length(FSCoder coder)
Specified by:
length in class FSTransformObject

encode

public void encode(FSCoder coder)
Specified by:
encode in class FSTransformObject

decode

public void decode(FSCoder coder)
Specified by:
decode in class FSTransformObject