Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.flagstone.transform
Class FSDefineFont2

    java.lang.Object
      com.flagstone.transform.FSTransformObject
          com.flagstone.transform.FSMovieObject
              com.flagstone.transform.FSDefineObject
                  com.flagstone.transform.FSDefineFont2

All Implemented Interfaces:
  java.lang.Cloneable

    public class FSDefineFont2

extends FSDefineObject

FSDefineFont2 defines the shapes and layout of the glyphs used in a font.

It extends the functionality provided by the FSDefineFont class by:

- allowing more than 65535 glyphs in a particular font.
- including the functionality provided by the FontInfo class.
- specifying ascent, descent and leading layout information for the font.
- specifying advances for each glyph.
- specifying bounding rectangles for each glyph.
- specifying kerning pairs defining the distance between pairs of glyphs.

The FSDefineFont2 class combines the attributes of the FSFontInfo and FSDefineFont classes:

Attributes
type | Identifies the data structure when it is encoded. The type attribute is read-only and may be used when iterating through the objects in an FSMovie object to identify the object class without using run-time type checking.
identifier | The unique identifier for this object.
encoding | Specifies whether the font codes are ANSI, SJIS or Unicode.
language | Identifies the spoken language for the font, either FSText.Japanese, FSText.Korean, FSText.Latin, FSText.SimplifiedChinese, FSText.TraditionalChinese. This attribute is used when displaying text fields and assists in determining language-appropriate line breaks.
italic | Whether the font is italicised.
bold | Whether the font is bold.
small | Small point size fonts will be drawn aligned to pixel boundaries to improve rendering.
name | The name of the font.
shapes | An array of FSShape objects that define the outline for each glyph.
codes | An array mapping a glyph index to a particular character code in the font.

Additional layout information for the glyphs in the font can also be specified through the following set of attributes:

ascent | The maximum ascent for the font in twips.
descent | The maximum descent for the font in twips.
leading | The leading for the font.
advances | An array of integers that define the advance for each glyph in the font.
bounds | An array of FSBounds object that define the bounding rectangle for each glyph in the font.
kernings | An array of FSKerning objects that define adjustment to the advance for particular pairs of glyphs in the font.

The default values for the ascent, descent and leading attributes is zero and the arrays containing the advances, bounds and kernings are empty. If the attributes all set to their default values then the layout information will not be encoded. All the values must be set and the arrays must contain the same number of entries as there are glyphs before the layout information will be encoded.

# History

The FSDefineFont2 class represents the DefineFont2 structure from the Macromedia Flash (SWF) File Format Specification. It was introduced in Flash 2. Support for spoken languages was added in Flash 6. Support for small point size fonts was added in Flash 7.

Field Summary

Fields inherited from class com.flagstone.transform.FSDefineObject
`identifier`

Fields inherited from class com.flagstone.transform.FSMovieObject
`ButtonColorTransform, ButtonSound, DefineBitsPtr, DefineButton, DefineButton2, DefineFont, DefineFont2, DefineImage, DefineImage2, DefineJPEGImage, DefineJPEGImage2, DefineJPEGImage3, DefineMorphShape, DefineMovieClip, DefineShape, DefineShape2, DefineShape3, DefineSound, DefineText, DefineText2, DefineTextField, DefineVideo, DoAction, EnableDebugger, EnableDebugger2, Export, extendLength, FontInfo, FontInfo2, FrameLabel, Free, Import, Initialize, JPEGTables, length, LimitScript, PathsArePostscript, PlaceObject, PlaceObject2, Protect, QuicktimeMovie, RemoveObject, RemoveObject2, SerialNumber, SetBackgroundColor, ShowFrame, SoundStreamBlock, SoundStreamHead, SoundStreamHead2, StartSound, TabOrder, type, VideoFrame`

Constructor Summary
`FSDefineFont2(FSCoder coder)` Construct an FSDefineFont2 object, initalizing it with values decoded from an encoded object.
`FSDefineFont2(FSDefineFont2 obj)` Constructs an FSDefineFont2 object by copying values from an existing object.
`FSDefineFont2(int anIdentifier, java.lang.String name)` Constructs an FSDefineFont2 object specifying only the name of the font.

Method Summary
`void` | `add(FSBounds anObject)` Add a bounds object to the array of bounds for each glyph.
`void` | `add(FSKerning anObject)` Add a kerning object to the array of kernings for pairs of glyphs.
`void` | `add(FSShape anObject)` Add a shape to the array of shapes.
`void` | `addAdvance(int anAdvance)` Add an advance to the array of advances.
`void` | `addCode(int aCode)` Add a code to the array of codes.
`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.
`java.lang.Object` | `clone()` Creates a deep copy of the entire object.
`void` | `decode(FSCoder coder)`
`void` | `encode(FSCoder coder)`
`boolean` | `equals(java.lang.Object anObject)` Returns true if anObject is equal to this one.
`java.util.ArrayList` | `getAdvances()` Gets the array of advances defined for each glyph in the font.
`int` | `getAscent()` Gets the ascent for the font in twips.
`java.util.ArrayList` | `getBounds()` Gets the array of bounding rectangles defined for each glyph in the font.
`java.util.ArrayList` | `getCodes()` Gets the array of codes used to identify each glyph in the font.
`int` | `getDescent()` Gets the descent for the font in twips.
`int` | `getEncoding()` Gets the encoding used for the font codes, either FSText.ASCII, FSText.SJIS or FSText.Unicode.
`java.util.ArrayList` | `getKernings()` Gets the array of kerning records that define the spacing between glyph pairs.
`int` | `getLanguage()` Gets the language code identifying the type of spoken language for the font either FSText.Japanese, FSText.Korean, FSText.Latin, FSText.SimplifiedChinese or FSText.TraditionalChinese.
`int` | `getLeading()` Gets the leading for the font in twips.
`java.lang.String` | `getName()` Gets the name of the font family.
`java.util.ArrayList` | `getShapes()` Gets the array 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` | `length(FSCoder coder)`
`void` | `setAdvances(java.util.ArrayList anArray)` Sets the array 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(java.util.ArrayList anArray)` Sets the array of bounding rectangles for each glyph in the font.
`void` | `setCodes(java.util.ArrayList anArray)` 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(int aType)` Sets the encoding for the font character codes.
`void` | `setItalic(boolean aBool)` Set the font is italicised.
`void` | `setKernings(java.util.ArrayList anArray)` Sets the array of kerning records for pairs of glyphs in the font.
`void` | `setLanguage(int code)` 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(java.lang.String aString)` Set the name of the font.
`void` | `setShapes(java.util.ArrayList anArray)` Set the array of shape records that define the outlines of the characters used from the font.
`void` | `setSmall(boolean aBool)` Sets the font is small.

Methods inherited from class com.flagstone.transform.FSDefineObject
`getIdentifier, setIdentifier`

Methods inherited from class com.flagstone.transform.FSMovieObject
`getType`

Methods inherited from class com.flagstone.transform.FSTransformObject
`name, toString`

Methods inherited from class java.lang.Object
`finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Constructor Detail

### FSDefineFont2

    public FSDefineFont2(FSCoder coder)

  Construct an FSDefineFont2 object, initalizing it with values decoded from an encoded object.

  Parameters:
    `coder` - an FSCoder containing the binary data.

### FSDefineFont2

    public FSDefineFont2(int anIdentifier,
                         java.lang.String name)

  Constructs an FSDefineFont2 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 FSDefineTextField 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:
    `anIdentifier` - the unique identifier for this object.
    `name` - the name of the font.

### FSDefineFont2

    public FSDefineFont2(FSDefineFont2 obj)

  Constructs an FSDefineFont2 object by copying values from an existing object.

  Parameters:
    `obj` - an FSDefineFont2 object.

Method Detail

### add

    public void add(FSShape anObject)

  Add a shape to the array of shapes.

  Parameters:
    `anObject` - a shape.

### addCode

    public void addCode(int aCode)

  Add a code to the array of codes.

  Parameters:
    `aCode` - a code for a glyph.

### addAdvance

    public void addAdvance(int anAdvance)

  Add an advance to the array of advances.

  Parameters:
    `anAdvance` - an advance for a glyph.

### add

    public void add(FSBounds anObject)

  Add a bounds object to the array of bounds for each glyph.

  Parameters:
    `anObject` - an FSBounds.

### add

    public void add(FSKerning anObject)

  Add a kerning object to the array of kernings for pairs of glyphs.

  Parameters:
    `anObject` - an FSKerning.

### getEncoding

    public int getEncoding()

  Gets the encoding used for the font codes, either FSText.ASCII, FSText.SJIS or FSText.Unicode.

  Returns:
    the encoding used to represent characters rendered in the font.

### 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 int getLanguage()

  Gets the language code identifying the type of spoken language for the font either FSText.Japanese, FSText.Korean, FSText.Latin, FSText.SimplifiedChinese or FSText.TraditionalChinese.

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

### setLanguage

    public void setLanguage(int code)

  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:
    `code` - the code identifying the spoken language either FSText.Japanese, FSText.Korean, FSText.Latin, FSText.SimplifiedChinese or FSText.TraditionalChinese.

### getName

    public java.lang.String getName()

  Gets the name of the font family.

  Returns:
    the name of the font.

### getShapes

    public java.util.ArrayList getShapes()

  Gets the array of shapes used to define the outlines of each font glyph.

  Returns:
    an array of FSShape objects

### getCodes

    public java.util.ArrayList getCodes()

  Gets the array 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 array.

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

### getAscent

    public int getAscent()

  Gets the ascent for the font in twips.

  Returns:
    the ascent for the font.

### getDescent

    public int getDescent()

  Gets the descent for the font in twips.

  Returns:
    the descent for the font.

### getLeading

    public int getLeading()

  Gets the leading for the font in twips.

  Returns:
    the leading for the font.

### getAdvances

    public java.util.ArrayList getAdvances()

  Gets the array of advances defined for each glyph in the font.

  Returns:
    an array of Integer objects that contain the advance for each glyph in the font.

### getBounds

    public java.util.ArrayList getBounds()

  Gets the array of bounding rectangles defined for each glyph in the font.

  Returns:
    an array of FSBounds objects.

### getKernings

    public java.util.ArrayList getKernings()

  Gets the array of kerning records that define the spacing between glyph pairs.

  Returns:
    an array of FSKerning objects that define the spacing adjustment between pairs of glyphs.

### setEncoding

    public void setEncoding(int aType)

  Sets the encoding for the font character codes.

  Parameters:
    `aType` - the encoding scheme used to denote characters, either FSText.ASCII, FSText.SJIS or FSText.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(java.lang.String aString)

  Set the name of the font.

  Parameters:
    `aString` - the name assigned to the font, identifying the font family.

### setShapes

    public void setShapes(java.util.ArrayList anArray)

  Set the array of shape records that define the outlines of the characters used from the font.

  Parameters:
    `anArray` - an array of FSShape objects that define the glyphs for the font.

### setCodes

    public void setCodes(java.util.ArrayList anArray)

  Sets the codes used to identify each glyph in the font.

  Parameters:
    `anArray` - sets the code table that maps a particular glyph to a character code.

### setAscent

    public void setAscent(int aNumber)

  Sets the ascent for the font in twips.

  Parameters:
    `aNumber` - the ascent for the font.

### setDescent

    public void setDescent(int aNumber)

  Sets the descent for the font in twips.

  Parameters:
    `aNumber` - the descent for the font.

### setLeading

    public void setLeading(int aNumber)

  Sets the leading for the font in twips.

  Parameters:
    `aNumber` - the descent for the font.

### setAdvances

    public void setAdvances(java.util.ArrayList anArray)

  Sets the array of advances for each glyph in the font.

  Parameters:
    `anArray` - of Integer objects that define the spacing between glyphs.

### setBounds

    public void setBounds(java.util.ArrayList anArray)

  Sets the array of bounding rectangles for each glyph in the font.

  Parameters:
    `anArray` - an array of FSBounds objects that define the bounding rectangles that enclose each glyph in the font.

### setKernings

    public void setKernings(java.util.ArrayList anArray)

  Sets the array of kerning records for pairs of glyphs in the font.

  Parameters:
    `anArray` - an array of FSKerning objects that define an adjustment applied to the spacing between pairs of glyphs.

### clone

    public java.lang.Object clone()

  Description copied from class: `FSTransformObject`
  Creates a deep copy of the entire object.

  Overrides:
    `clone` in class `FSTransformObject`
  Returns:
    a copy of the object.

### equals

    public boolean equals(java.lang.Object anObject)

  Description copied from class: `FSMovieObject`
  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 `FSMovieObject`
  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.

  Overrides:
    `appendDescription` in class `FSDefineObject`
  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)

  Overrides:
    `length` in class `FSDefineObject`

### encode

    public void encode(FSCoder coder)

  Overrides:
    `encode` in class `FSDefineObject`

### decode

    public void decode(FSCoder coder)

  Overrides:
    `decode` in class `FSDefineObject`

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD