Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

AE: Parenting text styles doesn't include character width?

Engaged ,
Feb 23, 2024 Feb 23, 2024

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?

TOPICS
Expressions , How to
426
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Feb 23, 2024 Feb 23, 2024

It's normal using style object you have access to the first character style of your string.

  • Font
  • Font Size
  • Faux Bold
  • Faux Italics
  • All Caps
  • Small Caps
  • Tracking
  • Leading
  • Auto Leading
  • Baseline Shift
  • Fill (enable/disable)
  • Fill Color
  • Stroke (enable/disable)
  • Stroke Color
  • Stroke Width

 

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

 

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Feb 23, 2024 Feb 23, 2024

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 23, 2024 Feb 23, 2024

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

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Feb 23, 2024 Feb 23, 2024
LATEST

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

 

 screenshot.png

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines