Answers.Body: <p>It's not possible directly from what I understand, but you can make a &quot;faux text box&quot; and alter the scale while inversely altering the text size and leading.</p>
  <p>For example, add a paragraph text box and resize it (closely) to 1920x1080. Drag the anchor to the upper left corner. The anchor point will be the point the text box scales from. Then add 3 sliders to the text layer: FontSize, TextBoxWidth, and FontLeading. Set these sliders to arbitrary values to start, maybe 16 for FontSize, 800 for TextBoxWidth, and 1.6 for FontLeading.</p>
  <p>Add this as the Source Text expression</p>
  <pre><code>textSize = effect(&quot;FontSize&quot;)(&quot;Slider&quot;);
  targetWidth = effect(&quot;TextBoxWidth&quot;)(&quot;Slider&quot;);
  textLeading = effect(&quot;FontLeading&quot;)(&quot;Slider&quot;);
  originalBoxWidth = 1920;
  
  boxScale = targetWidth / originalBoxWidth;
  
  text.sourceText.style.setFontSize(textSize / boxScale).setLeading(textSize * textLeading / boxScale);
  </code></pre>
  <p>Add this expression to Transform &gt; Scale of the text layer.</p>
  <pre><code>targetWidth = effect(&quot;TextBoxWidth&quot;)(&quot;Slider&quot;);
  originalBoxWidth = 1920;
  
  boxScale = targetWidth / originalBoxWidth;
  
  value * boxScale;
  </code></pre>
  <p>You'll then be able to adjust the sliders to set the text box width, font size, and leading.</p>
  <p>See this video for more details: <div class="youtube-embed"><div>
                  <iframe width="640px" height="395px" src="https://www.youtube.com/embed/FpVPabZw3vU?start=0"></iframe>
              </div></div></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-05-15T21:22:14.597Z
Answers.LastActivityDate: 2023-05-15T21:22:14.597Z
Answers.UserDisplayName: D34DC3N73R
Body: <p>I'm building a <a href="https://helpx.adobe.com/premiere-pro/using/motion-graphics-templates.html" rel="nofollow noreferrer">Mogrt</a> using After Effects.
  I need to be able to drive the size of a paragraph text box dynamically using expressions.</p>
  <p>Is that possible?
  I can't find a parameter related to this.</p>
  
Tags: <after-effects>
Title: Resize a paragraph text box in After Effects using expressions
UserDisplayName: gordie
ThreadText: # Resize a paragraph text box in After Effects using expressions
  
  (Asked by: username_0 on 2023-04-21)
  
  I'm building a [Mogrt](https://helpx.adobe.com/premiere-pro/using/motion-graphics-templates.html) using After Effects.
  I need to be able to drive the size of a paragraph text box dynamically using expressions.
  
  Is that possible?
  I can't find a parameter related to this.
  
  **Tags:** after-effects
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2023-05-15. Score: 0
  
  It's not possible directly from what I understand, but you can make a "faux text box" and alter the scale while inversely altering the text size and leading.
  
  For example, add a paragraph text box and resize it (closely) to 1920x1080. Drag the anchor to the upper left corner. The anchor point will be the point the text box scales from. Then add 3 sliders to the text layer: FontSize, TextBoxWidth, and FontLeading. Set these sliders to arbitrary values to start, maybe 16 for FontSize, 800 for TextBoxWidth, and 1.6 for FontLeading.
  
  Add this as the Source Text expression
  
  ```
  textSize = effect("FontSize")("Slider");
  targetWidth = effect("TextBoxWidth")("Slider");
  textLeading = effect("FontLeading")("Slider");
  originalBoxWidth = 1920;
  
  boxScale = targetWidth / originalBoxWidth;
  
  text.sourceText.style.setFontSize(textSize / boxScale).setLeading(textSize * textLeading / boxScale);
  
  ```
  
  Add this expression to Transform > Scale of the text layer.
  
  ```
  targetWidth = effect("TextBoxWidth")("Slider");
  originalBoxWidth = 1920;
  
  boxScale = targetWidth / originalBoxWidth;
  
  value * boxScale;
  
  ```
  
  You'll then be able to adjust the sliders to set the text box width, font size, and leading.
  
  See this video for more details:
  
  
  ---
  
  