• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Controllable Font Weights – style.setFont with an Expression Selector

New Here ,
Oct 01, 2020 Oct 01, 2020

Copy link to clipboard

Copied

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!

TOPICS
Expressions

Views

971

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Explorer , Oct 02, 2020 Oct 02, 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

...

Votes

Translate

Translate
Explorer ,
Oct 02, 2020 Oct 02, 2020

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Oct 02, 2020 Oct 02, 2020

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 09, 2020 Oct 09, 2020

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Apr 08, 2021 Apr 08, 2021

Copy link to clipboard

Copied

Just posted the same question, before I found this.
Any possibility of getting the test file as well, so I can adapt it to what I need?
Thanks!!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 08, 2021 Apr 08, 2021

Copy link to clipboard

Copied

Sure, this is a slightly updated version. It only works with left aligned text, but you can amend the position expression to fix that. 

 

If you want to change the text size and leading you do it on the master text layer, I found the auto leading doesn't always work for some reason.

 

https://we.tl/t-IHI2p4ab1z

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Apr 09, 2021 Apr 09, 2021

Copy link to clipboard

Copied

Awesome, thanks!
Checking it now. Will post back if/when I've found a solution!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Apr 09, 2021 Apr 09, 2021

Copy link to clipboard

Copied

OK, that totally did what it was supposed to do!
There was a slight error with the 3rd part of the line not attaching correctly to the bold part, but adding the sourceRectAtTime().left data fixed it :

previousText = thisComp.layer(index-1); x = previousText.position + previousText.sourceRectAtTime().width + previousText.sourceRectAtTime().left;

Perfect !!  THANKS SO MUCH!!
This now opens up lots of new possibilities!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 27, 2021 Jul 27, 2021

Copy link to clipboard

Copied

is there a way to post the full code?  interested in doing the same thing but the wetransfer links expired and can't figure out how to do this either

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 30, 2023 May 30, 2023

Copy link to clipboard

Copied

LATEST

VFX Bear, do you still happen to have the full code for this? The links expired, and I'd love to know more about how this was resolved. Would like to know if this expression is on the scale parameter, as this is where I'm finding most of the expressions need to go in order to align them to previous layers. 

Thanks for any and all help!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 29, 2022 Apr 29, 2022

Copy link to clipboard

Copied

Hello! Link is expired, possible to upload a new one? Thank you!

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 11, 2023 Jan 11, 2023

Copy link to clipboard

Copied

Hi, the link is expired. Could you please share it again?

 

Thank you 😄

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines