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

setTextWidth

Participant ,
Jun 30, 2022 Jun 30, 2022

Is there a way to set the width of a block of paragraph text via expressions?

 

Looked in the docs, but no such funtion exists.

 

 

TOPICS
Expressions
432
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 ,
Jun 30, 2022 Jun 30, 2022

I don't think there's any way to do that with an expression.

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 ,
Jun 30, 2022 Jun 30, 2022

There's no direct expression access to that function (probably possible with scripting, but likely wouldn't be the elegant solution you're hoping for). 

The solutions for this are usually a bit hacky and annoying - fortunately, I recently stumbled onto this preset, which makes it easy! https://rossowens.gumroad.com/l/textbox

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
Participant ,
Jun 30, 2022 Jun 30, 2022

that's interesting, thanks

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 ,
Jun 30, 2022 Jun 30, 2022
LATEST

The only thing you could do with expressions would be to tie the layer's scale to the sourceRectAtTime().width of the layer so that the true size would always be the same. Two words would scale up until they were 500 pixels wide, and four words would scale down until they were 500 pixels wide. I almost never write an expression using sourceRectAtTime() that does not combine ".left, .right, height, width and scale * .01" to compensate for layer scale. It should not be difficult to reverse the process. You could not force a line feed, but you could keep a text layer the same width no matter how many characters were in it. It might be an interesting visual effect. 

 

Here's the basic starting point for all my sourceRectAtTime() expressions.

ref = thisComp.layer(index - 1);
refPos = ref.position;
refSize = ref.sourceRectAtTime();
xOfst = refSize.width / 2 + refSize.left;
yOfst = refSize.height / 2 + refSize.top;

x = xOfst;
y = yOfst;


refPos + [x, y]

The expression centers the Anchor point of any layer below a text layer over the center of the text.

 

If you want to fiddle with expressions maybe that will get you started.

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