Copy link to clipboard
Copied
So I have this expression in one of my projects:
style = comp("Templates").layer("First Line Second Line").text.sourceText.style
And I noticed that it seems to capture everything except the character widths. Is that a bug or is there some additional step required to bring that property over?
Copy link to clipboard
Copied
It's normal using style object you have access to the first character style of your string.
You can get the width of your string using sourceRectAtTime()
sourceRectAtTime(t = time, includeExtents = false)
Return type: JavaScript object with four attributes: [top, left, width, height]. Extents apply only to shape layers, increasing the size of the layer bounds as necessary, and paragraph text layers (After Effects 15.1 and later), where it returns the bounds of the paragraph box. Example:
myTextLayer.sourceRectAtTime().width
Copy link to clipboard
Copied
NOT what I was referring to. You're talking about the width of the text layer. I'm talking about the horizontal scale as set in the Character properties panel.
Copy link to clipboard
Copied
Unfortunately, that's not one of the text attributes avialable to expressions, as listed here:
https://helpx.adobe.com/after-effects/using/expressions-text-properties.html
Copy link to clipboard
Copied
You can calculate the width difference between the two layers and extract the horizontal percentage scale value.
Then apply this value to transform the X Scale value.
copy text layer > source text expression:
src=thisComp.layer("my text").text.sourceText;
style = src.style.setText(src);
copy text layer > scale expression:
src=thisComp.layer("my text");
w1 = src.sourceRectAtTime().width;
w2 = sourceRectAtTime().width;
[(w1/w2) * 100, value[1]]
Find more inspiration, events, and resources on the new Adobe Community
Explore Now