Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions AE2020 – Change font if text includes :

  • AE2020 – Change font if text includes :

    Posted by Mathias Kalhauge on November 13, 2020 at 11:14 am

    I have a text layer that I want to change font, if a certain requirement is met.

    I currently have this expression, which changes the font of the Source text, by setting the ‘selection’ to one of two values (0 or 1):

    selection = [‘Regular’, ‘Bold’];

    fontFam = thisProperty.style.font.split(‘-‘);

    createStyle().setFont(fontFam[0] + ‘-‘ + selection[0]);


    I’m looking for an “if else” statement (or something similar) where if the Source text includes ‘:’ then ‘selection’ turns to 1 instead of 0


    Can one of the expression wizards in here see a solution to this?

    Mathias Kalhauge replied 5 years, 5 months ago 2 Members · 2 Replies
  • 2 Replies
  • Trent Armstrong

    November 13, 2020 at 2:54 pm

    I left some spots where you can put your code. Just get rid of the “//” and all the code thereafter for those lines. Also, go check out https://www.w3schools.com/js/default.asp where you can find a lot of wonderful ways to use Javascript for Expressions magic.

    txt = text.sourceText;

    temp = txt.search(“:”);

    if (temp > 0) {

    //[code for : exists]

    } else {

    //[code for : doesn’t exist]

    }

  • Mathias Kalhauge

    November 19, 2020 at 1:20 pm

    You sir are a saint!

    And I much appreciate the link. Great stuff!

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