com.flagstone.transform.text
Class TextSettings

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

public final class TextSettings
extends Object
implements MovieTag

TextSettings allows you to control how individual text fields are rendered.

There are four parameters that control how the text is rendered:

  1. Advanced Rendering - whether the text is rendered using the advanced anti-aliasing engine added in Flash 8.
  2. Grid Alignment - how letters are aligned with respect to the pixel grid used in LCD monitors.
  3. Thickness - a parameter used to control the thickness of the line when anti-aliasing is used.
  4. Sharpness - a parameter used to control the sharpness of the line when anti-aliasing is used.

The thickness and sharpness control the how the text is rendered:

    outsideCutoff = (0.5 * sharpness - thickness) * fontSize
    insideCutoff = (-0.5 * sharpness - thickness) * fontSize
 
Note that Adobe reports the results can be poor when the text is scaled by a significant amount and so the default values of 0.0 should be used for the thickness and sharpness values.


Nested Class Summary
static class TextSettings.Grid
          Grid specifies how letters are aligned with respect to the pixel grid on a screen.
 
Constructor Summary
TextSettings(int uid, boolean advanced, TextSettings.Grid grid, float thick, float sharp)
          Creates a TextSettings object with the specified values.
TextSettings(SWFDecoder coder)
          Creates and initialises an TextSettings using values encoded in the Flash binary format.
TextSettings(TextSettings object)
          Creates an TextSettings object and initialised it by copying the values from an existing one.
 
Method Summary
 TextSettings copy()
          Creates a complete copy of this object.
 void encode(SWFEncoder coder, Context context)
          Encode an object to the Flash binary format.
 TextSettings.Grid getGrid()
          Returns the alignment of letters with respect to the pixel grid.
 int getIdentifier()
          Get the unique identifier of the text definition that this object applies to.
 float getSharpness()
          Get the value used to control the sharpness of a line when rendered.
 float getThickness()
          Get the value used to control the thickness of a line when rendered.
 int prepareToEncode(Context context)
          Prepare an object for encoding, returning the expected size of an object when it is encoded.
 void setGrid(TextSettings.Grid alignment)
          Selects how the text letters will be aligned with respect to the pixel grid used in LCD screens.
 void setIdentifier(int uid)
          Sets the identifier of the text definition that this object applies to.
 void setSharpness(float level)
          Sets the value used to control the sharpness of a line when rendered.
 void setThickness(float level)
          Sets the value used to control the thickness of a line when rendered.
 String toString()
           
 boolean useAdvanced()
          Will the advanced text rendering engine, introduced in Flash 8 be used.
 void useAdvanced(boolean flag)
          Sets whether the advanced text rendering engine (true) or standard engine (false) will be used to render the text.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TextSettings

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

TextSettings

public TextSettings(int uid,
                    boolean advanced,
                    TextSettings.Grid grid,
                    float thick,
                    float sharp)
Creates a TextSettings object with the specified values.

Parameters:
uid - the unique identifier of an existing text field.
advanced - whether the advanced rendering engine will be used to display the text.
grid - how letters are aligned with respect to the pixel grid.
thick - the thickness used when anti-aliasing the text.
sharp - the sharpness used when anti-aliasing the text.

TextSettings

public TextSettings(TextSettings object)
Creates an TextSettings object and initialised it by copying the values from an existing one.

Parameters:
object - a TextSettings object.
Method Detail

getIdentifier

public int getIdentifier()
Get the unique identifier of the text definition that this object applies to.

Returns:
the unique identifier of the text object.

setIdentifier

public void setIdentifier(int uid)
Sets the identifier of the text definition that this object applies to.

Parameters:
uid - the unique identifier of an DefineText, DefineText2 or DefineTextField object. Must be in the range 1..65535.

useAdvanced

public boolean useAdvanced()
Will the advanced text rendering engine, introduced in Flash 8 be used.

Returns:
true if advanced text rendering is used, false if the standard rendering engine is used.

useAdvanced

public void useAdvanced(boolean flag)
Sets whether the advanced text rendering engine (true) or standard engine (false) will be used to render the text.

Parameters:
flag - set true to select the advanced text rendering engine, false for the standard rendering engine.

getGrid

public TextSettings.Grid getGrid()
Returns the alignment of letters with respect to the pixel grid.

Returns:
the alignment, either NONE, PIXEL or SUBPIXEL.

setGrid

public void setGrid(TextSettings.Grid alignment)
Selects how the text letters will be aligned with respect to the pixel grid used in LCD screens.

Parameters:
alignment - the alignment with respect to the pixel grid, either NONE, PIXEL or SUBPIXEL.

getThickness

public float getThickness()
Get the value used to control the thickness of a line when rendered. May be set to 0.0 if the default anti-aliasing value will be used.

Returns:
the adjustment applied to the line thickness.

setThickness

public void setThickness(float level)
Sets the value used to control the thickness of a line when rendered. May be set to 0.0 if the default anti-aliasing value will be used.

Parameters:
level - the value of the thickness parameter used by the rendering engine.

getSharpness

public float getSharpness()
Get the value used to control the sharpness of a line when rendered. May be set to 0.0 if the default anti-aliasing value will be used.

Returns:
the adjustment applied to the line sharpness.

setSharpness

public void setSharpness(float level)
Sets the value used to control the sharpness of a line when rendered. May be set to 0.0 if the default anti-aliasing value will be used.

Parameters:
level - the value of the sharpness parameter used by the rendering engine.

copy

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