Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Can character sizes be dictated by expressions?

  • Can character sizes be dictated by expressions?

    Posted by Russell Birkett on August 15, 2014 at 6:50 am

    Hi all
    Hoping someone might be able to guide me here.
    I have a number that starts off at 9.99 and have it increasing up to 30.00. What I am looking to do is to make the whole number larger in size than the fraction. I want the whole number to be about 200px and the fraction to be 100px. I’m kind of stuck. Any help would be appreciated.
    Russ

    existing code is simply . . .

    '$' + Math.round(effect("Slider Control")("Slider"))/100

    Filip Vandueren replied 12 years ago 2 Members · 1 Reply
  • 1 Reply
  • Filip Vandueren

    August 15, 2014 at 2:07 pm

    Hi Russel,

    Here’s how I would do it.

    First, change your expression to this:

    '$' + (Math.round(effect("Slider Control")("Slider"))/100).toFixed(2)

    The final toFixed(2) makes it so that the number after the comma is always 2 digits, otherwise you’d have 9 in stead of 9.00, or 9.1 instead go 9.10 etc.

    Next, add a text-animator for the property “Scale”

    In the timeline, Twirl open the Animator’s range-selector.
    Twirl open the range-selector’s Advanced properties.
    Change “Units” to “Index” (instead of the default percentage).

    Add this expression to Range Selector Start:
    text.sourceText.value.length-2;
    (If you want to include the period, use -3)

    Add this expression to Range Selector End:
    text.sourceText.value.length;

    Those expressions make sure this animator only affects the last two characters of whatever the text is.
    Now you can close the Range Selector’s twirl.

    Change the Animator’s Scale property to be 50%, 50%
    You’ll see that the letters get smaller, but their spacing doesn’t change.
    You can add an extra Property to the Animator to change that.

    Next to “Animator 1” Click Add: -> Property -> Tracking
    And tweak that to something like -50 for example, depends on your Font.

    Unfortunately tracking isn’t as intelligent as kerning, but in this examples where it only tracks numbers closer together, it is an acceptable solution, with words, it most often looks terrible.
    You’ll get best results with fixed width fonts (like courier, andale, monaco…)

    Extra tip: if you think the 50% text looks to thin/light next to the big one,
    Set the stroke color of the text to the same as the fill color.
    Set a stroke width of 0
    Now, add a Stroke width to the same animator, so only the two last digits get a stroke, tweak that width value to make them a bit bolder.

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy