Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Random Font for every Text Layer

  • Random Font for every Text Layer

    Posted by Dean Gregory on August 2, 2011 at 2:43 pm

    Hi there,

    I’m trying to come up with an expression for accessing the font info in After Effects.

    What I have is an array of multiple repeating words(say the word ‘Design’) that’s slowly moving randomly on the X-axis.

    The text is also displaced along Z-axis randomly.

    This looks very plain as all the words have the same font.

    All’s fine with the animation as well, but was wondering if I could now randomly change the font used for every word (i.e Design) to have a different look.

    I’m not too sure how to do this as the pick-whip for one will not access the Font menu.

    Is there any additional attribute to add say in sourcetext like ‘font’ or ‘font-family’.

    My thought was to access the font list if possible and then use random() to tag a random font to the text-layer.

    Have been struggling with this for a week now. Can anyone point me in the right direction? Thanks!

    AE version = CS5

    Cheers,

    Dean Gregory

    Dan Ebberts replied 12 years, 2 months ago 3 Members · 7 Replies
  • 7 Replies
  • Dan Ebberts

    August 2, 2011 at 3:52 pm

    Expressions can’t access/change fonts. You can do it with a script, but it wouldn’t be live, so you’d get your comp set up and then run the script.

    Another possibility would be to have multiple text layers parented together in a group, each with a different font, a source text expression linking them together, and a random opacity expression making only one layer of each group visible.

    Dan

  • Dean Gregory

    August 2, 2011 at 4:33 pm

    Hi there Dan,

    Thanks so much for your reply. The 2nd option does seem like a workaround.
    But was toying with a similar idea in Photoshop and decided to use Math.random to randomly select some fonts from an array.

    The code snippets are below.

    However, when trying similar code in AE, I can’t seem to make it happen.

    Is the “.font” possible in AE or is there another word for it like fontName or something?

    var fontArray = [
    "Tahoma",
    "Verdana",
    "Georgia",
    "Courier",
    "Default"
    ]

    txtRef.font = fontArray[Math.random()*fontArray.length|0];

  • Dean Gregory

    August 2, 2011 at 5:16 pm

    Hi there Dan,

    Was able to script it out. Got some clues from

    https://blogs.adobe.com/toddkopriva/2010/04/scripting-changes-in-after-eff.html

    the ‘.font’ works.
    Able to set up other attributes as well. Forgot about the ‘setValue’at the end hence it wasn’t showing up.

    Wish the new scripting guide would be out soon 🙂

    Cheers,

    Dean

  • Dan Ebberts

    August 2, 2011 at 5:17 pm

    I assume you’re talking about scripting now, and not expressions. Font access came in with AE CS4. Todd’s blog has a description of how it works:

    https://blogs.adobe.com/toddkopriva/2008/12/after-effects-cs4-scripting-ch.html

    Dan

  • Dean Gregory

    August 2, 2011 at 8:50 pm

    Hi Dan,

    Thanks a ton for sending me the link. Have bookmarked it! Great help!!

    Cheers,

    Dean

  • Justin Stephenson

    March 10, 2014 at 3:00 am

    I am trying to accomplish something similar here and I wanted to see how this might me done:

    “and a random opacity expression making only one layer of each group visible.”

    Any help would be appreciated.

    – Justin

    ————————-
    Design, Animation, Editing, Color for Cinema, Broadcast, Web and Installation.

    Gear: 2 X Macpro 8 Core Nehalem, ATTO R380, Proavio EB8MS, nVidia GTX-286, Blackmagic Decklink Studio, AJA LHi, FSI LM-2461W, Tangent Wave, Yamaha HS50Ms W HS10w Sub

    Tools: Avid MC 5.5 (formerly FCP), CS 5.5, C4D13, Resolve 8.1, VDMX, Quartz Composer, Processing, Cubase 5.

  • Dan Ebberts

    March 10, 2014 at 3:19 am

    Say you have a control layer (null) with a slider on it. You could use an opacity expression like this on each of your text layers:

    ctrl = thisComp.layer(“controls”).effect(“Slider Control”)(“Slider”);
    if (Math.round(ctrl) == index) 100 else 0

    Whichever layer index matches slider will be visible, the others will not. That should get you started.

    Dan

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