Skip to main content
Participant
October 1, 2020
Answered

Controllable Font Weights – style.setFont with an Expression Selector

  • October 1, 2020
  • 1 reply
  • 1863 views

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 animator 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!

This topic has been closed for replies.
Correct answer gregoryw80731704

To my knowledge you still can't bold parts of a sentance using expressions in AE you'll just get "The Quick Brown Fox, jumps over the [Object, object]."

The closest thing you can do is hook up multple text layers that move automatically depending on the length of the previous text. You can do that using the position and sourceRectAtTime().width in the expressions.

If you want to get clever with it you could have it so one text layer thats hidden controlls the rest of the layers by using .split so if you write something like:

“The *Quick Brown Fox*, jumps over the *Lazy Dogs*”

you will get

“The Quick Brown Fox, jumps over the Lazy Dogs

1 reply

gregoryw80731704Correct answer
Inspiring
October 3, 2020

To my knowledge you still can't bold parts of a sentance using expressions in AE you'll just get "The Quick Brown Fox, jumps over the [Object, object]."

The closest thing you can do is hook up multple text layers that move automatically depending on the length of the previous text. You can do that using the position and sourceRectAtTime().width in the expressions.

If you want to get clever with it you could have it so one text layer thats hidden controlls the rest of the layers by using .split so if you write something like:

“The *Quick Brown Fox*, jumps over the *Lazy Dogs*”

you will get

“The Quick Brown Fox, jumps over the Lazy Dogs

Inspiring
October 3, 2020

Can't edit my post for some reason. Made this test file.

Needs a bit of work but the general idea is there.

https://we.tl/t-xxHDTJAo1k

Ben5FB7Author
Participant
October 9, 2020

This is amazing, thank you. I think i can adapt this to work for my needs!