com.flagstone.transform.font
Class FontInfo2

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

public final class FontInfo2
extends Object
implements MovieTag

FontInfo2 is an updated version of FontInfo with support for spoken languages for improving line breaks when displaying text.

FontInfo2 defines the name and face of a font and maps the codes for a given character set to the glyphs that are drawn to represent each character. Support for languages and small fonts was added in Flash 7.

The class allows the font associated with a Flash file to be mapped to a font installed on the device where the Flash Player displaying the file is hosted. The use of a font from a device is not automatic but is determined by the HTML tag option deviceFont which is passed to the Flash Player when it is first started. If a device does not support a given font then the glyphs in the DefineFont class are used to render the characters.

An important distinction between the host device to specify the font and using the glyphs in an DefineFont object is that the device is not anti-aliased and the rendering is dependent on the host device. The glyphs in an DefineFont object are anti-aliased and are guaranteed to look identical on every device the text is displayed.

See Also:
FontInfo

Constructor Summary
FontInfo2(FontInfo2 object)
          Creates and initialises a FontInfo2 object using the values copied from another FontInfo2 object.
FontInfo2(int uid, String fontName, boolean isBold, boolean isItalic)
          Constructs a basic FontInfo2 object specifying only the name of the font.
FontInfo2(SWFDecoder coder)
          Creates and initialises a FontInfo2 object using values encoded in the Flash binary format.
 
Method Summary
 void addCode(int aCode)
          Add a code to the list of codes.
 FontInfo2 copy()
          Creates a complete copy of this object.
 void encode(SWFEncoder coder, Context context)
          Encode an object to the Flash binary format.
 List<Integer> getCodes()
          Get the list of character codes.
 CharacterFormat getEncoding()
          Get the encoding scheme used for characters rendered in the font, either ASCII, SJIS or UCS2.
 int getIdentifier()
          Get the unique identifier of the font definition that this font information is for.
 Language getLanguage()
          Returns the language code identifying the type of spoken language for the font.
 String getName()
          Get the name of the font family.
 boolean isBold()
          Is the font weight bold.
 boolean isItalic()
          Is the font style italics.
 boolean isSmall()
          Does the font have a small point size.
 int prepareToEncode(Context context)
          Prepare an object for encoding, returning the expected size of an object when it is encoded.
 void setBold(boolean aBool)
          Sets the font is bold.
 void setCodes(List<Integer> list)
          Sets the list of character codes.
 void setEncoding(CharacterFormat anEncoding)
          Sets the font character encoding.
 void setIdentifier(int uid)
          Sets the identifier of the font that this font information is for.
 void setItalic(boolean aBool)
          Sets the font is italics.
 void setLanguage(Language lang)
          Sets the language code used to determine the position of line-breaks in text rendered using the font.
 void setName(String aString)
          Sets the name of the font.
 void setSmall(boolean aBool)
          Sets the font is small.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FontInfo2

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

FontInfo2

public FontInfo2(int uid,
                 String fontName,
                 boolean isBold,
                 boolean isItalic)
Constructs a basic FontInfo2 object specifying only the name of the font.

Parameters:
uid - the unique identifier of the DefineFont that contains the glyphs for the font.
fontName - the name assigned to the font, identifying the font family.
isBold - indicates whether the font weight is bold (true) or normal (false).
isItalic - indicates whether the font style is italic (true) or plain (false).

FontInfo2

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

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

getIdentifier

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

Returns:
the unique identifier of the font.

getName

public String getName()
Get the name of the font family.

Returns:
the font name.

getEncoding

public CharacterFormat getEncoding()
Get the encoding scheme used for characters rendered in the font, either ASCII, SJIS or UCS2.

Returns:
the encoding used for the character codes.

isSmall

public boolean isSmall()
Does the font have a small point size. This is used only with a Unicode font encoding.

Returns:
true if the font is small.

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 style italics.

Returns:
true if the font is in italics.

isBold

public boolean isBold()
Is the font weight bold.

Returns:
true if the font weight is bold.

getLanguage

public Language getLanguage()
Returns the language code identifying the type of spoken language for the font.

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

getCodes

public List<Integer> getCodes()
Get the list of character codes.

Returns:
the list of character codes defined in the font.

setIdentifier

public void setIdentifier(int uid)
Sets the identifier of the font that this font 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.

setName

public void setName(String aString)
Sets the name of the font. The name be omitted (set to an empty string) if the font is embedded in the Flash file, i.e. the corresponding DefineFont object has all the glyph information.

Parameters:
aString - the name assigned to the font, identifying the font family. Must not be null.

setEncoding

public void setEncoding(CharacterFormat anEncoding)
Sets the font character encoding.

Parameters:
anEncoding - the encoding used to identify characters, either ASCII, SJIS or UNICODE.

setItalic

public void setItalic(boolean aBool)
Sets the font is italics.

Parameters:
aBool - a boolean flag indicating whether the font will be rendered in italics.

setBold

public void setBold(boolean aBool)
Sets the font is bold.

Parameters:
aBool - a boolean flag indicating whether the font will be rendered in bold face.

setLanguage

public void setLanguage(Language lang)
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:
lang - the Language identifying the spoken language for the text rendered using the font.

addCode

public void addCode(int aCode)
Add a code to the list of codes. The index position of a character code in the list identifies the index of the corresponding glyph in the DefineFont object.

Parameters:
aCode - a code for a glyph. Must be in the range 0..65535

setCodes

public void setCodes(List<Integer> list)
Sets the list of character codes.

Parameters:
list - the list mapping glyphs to particular character codes. The ordinal position of a character code in the list identifies the index of the corresponding glyph in the DefineFont object. Must not be null.

copy

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