Apple Developer Connection
Member Login Log In | Not a Member? Contact ADC

< Previous PageNext Page > Hide TOC

Modifying Text

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.


Figure 7-1  Modifying Text

editing

A Motion text object primarily relies on the following elements to specify its characteristics:

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.

In this section:

Modifying the text Element
Modifying the object Elements
Modifying the styleRun Element
Modifying the style Elements


Modifying the text Element

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>

Modifying the object Elements

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:

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

Modifying the styleRun Element

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:

Modifying the style Elements

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”).



< Previous PageNext Page > Hide TOC


Last updated: 2008-04-14




Did this document help you?
Yes: Tell us what works for you.

It’s good, but: Report typos, inaccuracies, and so forth.

It wasn’t helpful: Tell us what would have helped.
Get information on Apple products.
Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Copyright © 2007 Apple Inc.
All rights reserved. | Terms of use | Privacy Notice