ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Expression selectors to maintain multiple text formatting

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Jeff Hinkle
Expression selectors to maintain multiple text formatting
on May 31, 2017 at 6:42:31 pm

Hunting for a solution to the problem of using a master text layer to drive the source text of a slave text layer and have it keep multiple formatting attributes, I came across this Adobe forum post from 2009 (https://forums.adobe.com/thread/420410) and it is soooo close to what I need but my expression skills are simply not up to the challenge. Mainly trying to follow Mr. Ebberts' post about "replace the appropriate characters" and "replace them with the Unicode Zero Width Space character." Stealing A. Cobb's code and adding what I thought was code to target the "$" character, I got my $ placeholders to change, but think that's just because they were first in the text block. Further experiments have not yielded success.

Can anyone point me in the right direction for targeting the different characters? This would solve so many problems.

---
It is easier to destroy than to create.
More fun, too.


Return to posts index

Kevin Camp
Re: Expression selectors to maintain multiple text formatting
on May 31, 2017 at 9:33:26 pm

Hey Jeff!

you can use textIndex to isolate a character, compare it to a condition and then do something...

try adding a character value animator to a text layer and set the character value to 35 (#). then add an expression selector and add this to the expression selector amount:
txt = text.sourceText;
if ( txt[ textIndex - 1 ] == "$" ) 100 else 0;

if your text string contains a $ it should get changed to a #.

you mention formatting, so i'm not sure this is really what you are after, but maybe it will point you in the right direction...

Kevin Camp
Art Director
KCPQ, KZJO & KRCW


Return to posts index

Jeff Hinkle
Re: Expression selectors to maintain multiple text formatting
on Jun 1, 2017 at 2:07:00 pm

Hey, Kevin! Hope all is well back at The Q!

I tried merging something like that into the code I got from the original post (line 4) but it never seemed to work right. Adding a second Expression Selector targeting "#" just led to gibberish.

Overall view of what I'm trying to do: Have a slave text layer with text "$$$$####@@@" and multiple formatting (think $=day, #=time and @=time zone in different colors/sizes/weights), then pull its text from a master layer (or more if need be) that can be adjusted by a Premiere Live Text template. End result, editors can change show info in Premiere and the day/time formatting of the endpage will stay constant and kerning won't vary wildly.

MT = thisComp.layer("master").text.sourceText;  
ST = text.sourceText;  
myChar="$";
if(textIndex &lt;= ST.length && text.sourceText[textIndex-1] == myChar) STCode = ST.charCodeAt(textIndex-1) else STCode = 32;  
if(textIndex &lt;= MT.length && text.sourceText[textIndex-1] == myChar) MTCode = MT.charCodeAt(textIndex-1) else MTCode = 32;  
CV = text.animator("days").property.characterValue;  
((MTCode - STCode)/(CV - STCode))*100  


---
It is easier to destroy than to create.
More fun, too.


Return to posts index


Kevin Camp
Re: Expression selectors to maintain multiple text formatting
on Jun 1, 2017 at 8:27:18 pm

The Q's not too bad... though Laura, Jana and ile have left.. and then there's the Sinclair thing, we'll see how that pans out.

I think it's going to be really hard to do this using either a character offset or character change animator.... can you use separate text layers (day, time, timezone) and then use sourceRectAtTime() to keep the spacing between them regular? or is there something more complicated going on...?

Kevin Camp
Art Director
KCPQ, KZJO & KRCW


Return to posts index

Jeff Hinkle
Re: Expression selectors to maintain multiple text formatting
on Jun 2, 2017 at 3:07:55 pm

That's quite the exodus. Never thought Ile would leave.

Yeah, right now we're doing things with multiple text layers and trying to keep it all looking good. Seemed like it would work much better with a single multi-formatted text layer, which this process seemed like it would do if I could get it to work. Simplify setup on future projects as well. Hadn't tried sourceRectAtTime to keep spacing; might give that a spin. Thanks for the idea!

---
It is easier to destroy than to create.
More fun, too.


Return to posts index

Jeff Hinkle
Re: Expression selectors to maintain multiple text formatting
on Jun 6, 2017 at 1:58:27 pm

Don't think sourceRectAtTime() will work. We need to do things like 6P|5C with the "p", "c", and "|" needing to be different weights/sizes from the numbers and with flexible kerning. Short of five different text layers for every time, not sure how to make that work. That's why I was so keen on the original post that mentioned targeting specific characters and keeping their formatting constant. I just couldn't figure the character targeting. I need more JavaScript learnin'.

---
It is easier to destroy than to create.
More fun, too.


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]