Answers.Body: <p>Option 1 - use a fixed width font, and make sure the text layer you create is left aligned. You'll need to select the text in your layer before you switch the paragraph to left alignment.</p>
  <p>Option 2 -  Do something like this (I'm sure there's a nicer way to do it), but from looking at <a href="https://mediarealm.com.au/articles/after-effects-countdown-timer-expression/" rel="nofollow noreferrer">this script for countdown timers</a>, and <a href="https://ukramedia.com/charat-expression-in-after-effects/" rel="nofollow noreferrer">this script for finding the right character</a>, I hacked up this:</p>
  <p>Make a text layer for each character.</p>
  <p>Make sure each text layer is left aligned.</p>
  <p>Put this in the source text expression of each character you want to control:</p>
  <pre><code>st = 300;  
  t = st - time;  
  c = timeToTimecode(t);  
  c = c.substring(4,8)
  output = c.charAt(3);
  output
  </code></pre>
  <p>Change the “charAt” variable for each position. Eg 0 is the furthest right character, and (3) would be the furthest left character (the minute).</p>
  <p><a href="https://i.sstatic.net/lk0q1.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/lk0q1.jpg" alt="grab" /></a></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-03-22T20:06:36.573Z
Answers.LastActivityDate: 2023-03-22T22:18:13.610Z
Answers.LastEditDate: 2023-03-22T22:18:13.610Z
Answers.UserDisplayName: tomh
Body: <p>Using After Effects, I am trying to do a countdown of 5 minutes with a setup like this: 5m 00s, 4m 59s, 4m 58s... I have the countdown already set up with Slider Control. However, I'm trying to use a mask for each character separately, which I also mostly have under control, except I realized that the text moves when the width of the text box changes as the text changes, for example, 2m 00s vs 1m 59s because of the width of the character &quot;1&quot; is smaller than &quot;2&quot; in the font I am using. Is there a way I can make the text box width, specifically each character's placement, not change even while Slider is in use? I have already gotten started on creating changes to the mask each time it changes, but I have a feeling it will be a lot of work.</p>
  
Tags: <after-effects><after-effects-expressions>
Title: After Effects: How to keep text same width through changes
UserDisplayName: leguchi
ThreadText: # After Effects: How to keep text same width through changes
  
  (Asked by: username_0 on 2023-03-22)
  
  Using After Effects, I am trying to do a countdown of 5 minutes with a setup like this: 5m 00s, 4m 59s, 4m 58s... I have the countdown already set up with Slider Control. However, I'm trying to use a mask for each character separately, which I also mostly have under control, except I realized that the text moves when the width of the text box changes as the text changes, for example, 2m 00s vs 1m 59s because of the width of the character "1" is smaller than "2" in the font I am using. Is there a way I can make the text box width, specifically each character's placement, not change even while Slider is in use? I have already gotten started on creating changes to the mask each time it changes, but I have a feeling it will be a lot of work.
  
  **Tags:** after-effects, after-effects-expressions
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2023-03-22. Score: 0
  
  Option 1 - use a fixed width font, and make sure the text layer you create is left aligned. You'll need to select the text in your layer before you switch the paragraph to left alignment.
  
  Option 2 - Do something like this (I'm sure there's a nicer way to do it), but from looking at [this script for countdown timers](https://mediarealm.com.au/articles/after-effects-countdown-timer-expression/), and [this script for finding the right character](https://ukramedia.com/charat-expression-in-after-effects/), I hacked up this:
  
  Make a text layer for each character.
  
  Make sure each text layer is left aligned.
  
  Put this in the source text expression of each character you want to control:
  
  ```
  st = 300;  
  t = st - time;  
  c = timeToTimecode(t);  
  c = c.substring(4,8)
  output = c.charAt(3);
  output
  
  ```
  
  Change the “charAt” variable for each position. Eg 0 is the furthest right character, and (3) would be the furthest left character (the minute).
  
  [![grab](https://i.sstatic.net/lk0q1.jpg)](https://i.sstatic.net/lk0q1.jpg)
  
  
  ---
  
  