Suppose a Motion project contains a Motion text object whose text is set to “Welcome to Texas”. This text is written with two different fonts: Stone Sans Sem OS ITCTT (a system font) for “Welcome To,” and Script (a LiveFont) for “Texas.” Also, there is carriage return after the word “to.”
In this example, the goal is to change the word “Texas” to “California” and the font for “California” to Sunflower.
A Motion text object primarily relies on the following elements to specify its characteristics:
text
object
styleRun
style
In general, Motion text objects are subelements of a scenenode. If a Motion project contains multiple Motion text objects, each scenenode element with a Motion text object contains its own style, styleRun, text and object elements. To modify a text object, you need to first accurately identify its scenenode and then change the subelements.
Modifying the text Element
Modifying the object Elements
Modifying the styleRun Element
Modifying the style Elements
First, change the text element. Depending on your XML editor, it appears as:
<text>Welcome to |
Texas</text> |
Change this to:
<text>Welcome to |
California</text> |
Motion contains one object element for every glyph in the associated text object:
Listing 7-1 Initial Glyphs in the Text Object
<object value="87"><! letter "W" --> |
<parameter name="Kerning" id="1" flags="16" value="0" /> |
</object> |
<object value="101"><! letter "e" --> |
<parameter name="Kerning" id="2" flags="16" value="0" /> |
</object> |
<object value="108"><! letter "l" --> |
<parameter name="Kerning" id="3" flags="16" value="0" /> |
</object> |
. . . |
<object value="84"><! letter "T" --> |
<parameter name="Kerning" id="12" flags="16" value="0" /> |
</object> |
<object value="101"><! letter "e" --> |
<parameter name="Kerning" id="13" flags="16" value="0" /> |
</object> |
<object value="120"><! letter "x" --> |
<parameter name="Kerning" id="14" flags="16" value="0" /> |
</object> |
. . . |
Note the following:
The value= attribute of each object element represents the decimal ASCII value of the character for each glyph. The ASCII value should match the associated letter in the text element.
The id= of the Kerning parameter is equal to the index of each glyph, starting with 1.
For “Welcome to Texas,” there are 16 object elements, one for every character in the text element. As well, newline, tab, space and other whitespace characters require an object element.
Modifying the glyphs for “Welcome to California,” results in these object elements (partially shown):
Listing 7-2 Changed Glyphs in the Text Object
<object value="87"><! letter "W" --> |
<parameter name="Kerning" id="1" flags="16" value="0" /> |
</object> |
<object value="101"><! letter "e" --> |
<parameter name="Kerning" id="2" flags="16" value="0" /> |
</object> |
<object value="108"><! letter "l" --> |
<parameter name="Kerning" id="3" flags="16" value="0" /> |
</object> |
. . . |
<object value="67"><! letter "C" --> |
<parameter name="Kerning" id="12" flags="16" value="0" /> |
</object> |
<object value="97"><! letter "a" --> |
<parameter name="Kerning" id="13" flags="16" value="0" /> |
</object> |
<object value="108"><! letter "l" --> |
<parameter name="Kerning" id="14" flags="16" value="0" /> |
</object> |
. . . |
Motion uses styleRun elements to specify the range that text style elements refer to. Without properly specified styleRun elements, style elements, which encode font information, do not have any effect.
In the original project file, the styleRun elements appear as follows:
<styleRun style="10032" offset="0" length="11" /> |
<styleRun style="10107" offset="11" length="5" /> |
The style= attribute refers to the id= attribute of a style element. The length= attribute indictes the span of the styleRun.
The first styleRun element in this listing refers the style element that whose font is Stone Sans OS ITCTT. The first 11 characters snap the text “Welcome to “ (including the newline character).
The second styleRun element begins on the 12th character and spans 5 characters: “Texas”.
In the modified project file, the length of the string changes (since “Texas” changes to “California”). The styleRun elements then change as follows:
<styleRun style="10032" offset="0" length="11" /> |
<styleRun style="10107" offset="11" length="10" /> |
Note the following:
The offset= attribute of the first styleRun element, which refers to the first character the indicated style affects, is 0.
When the lengths of the text strings change, it is important to modify the appropriate styleRun element to ensure that the appropriate text style is applied to the new characters.
Every character in a text object must be associated with a styleRun. It is important to check for consistency across all styleRun elements and to ensure there are no overlaps and no gaps in the range of characters affected.
You can change the font applied to “Texas” from Script to Sunflower by modifying the appropriate style element. In the original project file, there are two style elements for the text object.
<style name="Style" id="10032" factoryID="1"> |
<font type="0">StoneSansOSITCTT-SemiIta</font> |
... |
</style> |
<style name="Style1" id="10107" factoryID="1"> |
<font type="1">Pro Series/Script</font> |
... |
</style> |
Since each font has a unique name and a different type, you can use the font element’s type= attribute to identify the font element you want to change. In this case, it is in the second style element with an id= 10107. (If the two style elements have similar characteristics, you can use the id= attribute and the associated styleRun element to identify the correct font element to change.)
The second font element, whose type attribute refers to a LiveFont and whose contents is the system name of the Script font, pertains to the style element that is associated with the styleRun element spanning the characters in “Texas.” It is then changed to the following:
<style name="Style" id="10032" factoryID="1"> |
<font type="0">StoneSansOSITCTT-SemiIta</font> |
... |
</style> |
<style name="Style1" id="10107" factoryID="1"> |
<font type="1">Pro Series/Sunflower</font> |
... |
</style> |
The id= of the second style element is 10107 and corresponds to the style= attribute of the styleRun element. This element applies to the word “California,” which now appears in the Sunflower font.
Note: You can change a font element in order to change the font used by a style. However, take care to represent the font name and type accurately. (See “font”).
Last updated: 2008-04-14