Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Controllable Font Weights – style.setFont with an Expression Selector

  • Controllable Font Weights – style.setFont with an Expression Selector

    Posted by Ben Oxford on September 30, 2020 at 4:59 pm

    Hi all,

    First post here after years of googling and nabbing sections of code!

    I’m trying to create a MOGRT with some unique functionality I haven’t seen anywhere else online. Our clients use two weights of font on their Video Captions (which currently they type manually) in order to highlight specific words within the text. So for example, they might like to style:

    “The Quick Brown Fox, jumps over the lazy dogs”

    as

    “The Quick Brown Fox, jumps over the Lazy Dogs

    The solution i’m currently using is a bit of a workaround, based on Jarle Leirpoll’s example in making Mogrts ebook.

    string = thisComp.layer("Highlighted Words").text.sourceText.split("+");

    result = 0;

    for (i = 0; i < string.length; i++){

    if (textIndex == parseInt(string[i],10)){

    result = 100;

    break;

    }

    }

    result

    Using this running through an expression selector in the Amount Setting, I can successfully tie this to a stroke width to give the characters a bit of extra thickness based on a simple code in a separate hidden text layer i.e

    1+3+4+5+9+10 Applies the effect to the corresponding word. Its quite intuitive for the client to understand.

    However this is a bit of a workaround and the font used with the 3.0 stroke weight doesn’t exactly match the other weight of font i’m trying to replicate. Is there a way to combine this method with something like style.setFont so that the highlighted words utilise the correct font weight?

    Hopefully that all makes sense!

    Any help would be greatly appreciated!

    Jon Miguel replied 5 years ago 5 Members · 10 Replies
  • 10 Replies
  • Filip Vandueren

    October 1, 2020 at 8:32 am

    Unfortunately No: After Effects does not allow you to set different Styles to differnt characters/words within a sourceText

  • Ben Oxford

    October 1, 2020 at 4:11 pm

    That is unfortunate, as I’m aware there is no way to do this using the Essential Graphics Panel, other than using the faux styles adjustment which affects the entire Source Text?

  • Filip Vandueren

    October 1, 2020 at 7:32 pm

    Actually, I’m working on something.
    I have it working for single and multi-line textlayers, but still some tests to do.

    Unfortunately it’s not sourcecode I’m willing to share publicly right now, as I’m pondering wether to offer it as a script on aescripts.

  • Bart Remmers

    October 1, 2020 at 8:23 pm

    Keep me posted on this too. I’d love to know!

  • Ben Oxford

    October 1, 2020 at 8:29 pm

    Either way I’d be very interested!

  • Filip Vandueren

    October 6, 2020 at 8:32 pm

    Here’s the state I’m at now.
    It works perfectly well (though rather slow) inside of After Effects.

    But unfortunately it’s glitchy as hell once it’s a Mogrt in Premiere:

    https://www.dropbox.com/s/wprxdr5rzw2ueut/Screen%20Recording%202020-10-06%20at%2022.21.03.mov?dl=0

    Quite frustrating as you can tell…

  • Andrei Popa

    October 7, 2020 at 5:23 am

    The “randomly sometimes work” could be caused by using the sourceRectAtTime() on a layer on which you modify the leading, fontsize, fonWeight(basically anything that changes the sourceRectAtTime).

    I tried decreasing/increasing a font size until it filled the boxText and had the same behaviour.

  • Filip Vandueren

    October 7, 2020 at 8:53 am

    Thanks for the tip Andrei, we can see the numbers (that I visualized to debug) glitching too. Very annoying.

  • Ben Oxford

    October 9, 2020 at 9:24 am

    Wow, Filip this looks great, despite the bugs, functionally this is exactly what I was looking for. I’m too much of a noob when it comes to expressions to help figure out why its glitchy but If you do end up making any progress on this I’d love to see it. Paid Script or otherwise!

  • Jon Miguel

    April 22, 2021 at 3:55 pm

    I’m also trying to find the solution for this if there’s a way to do this. I’m in the same boat

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