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

Control Font Weight Expression

Community Beginner ,
Feb 27, 2022 Feb 27, 2022

Copy link to clipboard

Copied

I am currently working on an Essential Graphics Template for a client. For this template I need the option to change font weight inside a text layer. Attached you see a picture of my problem.

 

Screenshot 2022-02-28 082447.png

Can anyone help me with an expression to control the font weight inside a text layer? I already know, that I have to split the different font weights in seperate layers and control the main text layer via sourceRectAtTime but I can't figure out where to write the code needed for this to work.

 

I've seen a post, where the same topic was discussed, but because the link expired I can't see the full code of the solution to my problem. Here the link to the other post: https://community.adobe.com/t5/after-effects-discussions/controllable-font-weights-style-setfont-wit...

 

Thanks in advance for your help!

 

TOPICS
Expressions

Views

788

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
LEGEND ,
Feb 27, 2022 Feb 27, 2022

Copy link to clipboard

Copied

It seems you're making this unnecessarily complicated. If the layers are separate, you don't need any advanced expressions and can just link the font selection directly. Calculating the line wrapping is a whole different story, but that won't work reliably with paragraph text, anyway, given that the Adobe Type Engine does its own magic internally. You have to use conventional line text. Therefore it might help to actually know what the texts are supposed to be rather than throwing around lorem ipsum. In fact if you used a monospaced font you wouldn't even need convoluted calculations for the positioning, just manipulate the text string.

 

Mylenium

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
Community Beginner ,
Feb 28, 2022 Feb 28, 2022

Copy link to clipboard

Copied

Thanks Mylenium for your reply!
As far as I read it in the other post that I linked, I have to seperate the layers so that I can make one layer "Light" and the other "Bold" font weight.
The advantage of the paragraph text would be, that the lines break automatically and it would be more customer friendly in the usage of the MOGRT.
Because the text is part of a template it can be random and I can't tell you what it exactly will be. That's why I used "lorem ipsum" as a placeholder.
And also the problem is, that the corporate fonts I have to use is not a monospaced font.

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
LEGEND ,
Feb 28, 2022 Feb 28, 2022

Copy link to clipboard

Copied

Then I guess you'll have to indeed run through the whole rigmarole of figuring out the indices and splicing stuff. Have you tried contacting the original author from that linked thread?

 

Mylenium

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
Community Beginner ,
Feb 28, 2022 Feb 28, 2022

Copy link to clipboard

Copied

Yes I already did. But unfortunately I got no response. 

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
Community Expert ,
Feb 28, 2022 Feb 28, 2022

Copy link to clipboard

Copied

It sounds like you're already aware that you can't mix weights/styles within a single text layer if it's part of a Mogrt template. 

 

The best solution I've found for this limitation, which is doing essentially the same thing in a less code-y way:

  • Create a duplicate of your original text layer, and set the style for this new one as desired - bold, in your case. 
  • Pickwhip the Source Text property of your Bold layer to the same property on the original text layer. 
  • Bold layer: Add a text animator for Opacity. Set Advanced > Units to Index. Set Advanced > Based On to Words. Now use the Start and End to adjust the words visible as Bold. 
    • Add these StartEnd controls to the EGP, or connect them to sliders that will be added to the EGP. 
  • Copy/paste this text animator to the original text layer. Set Advanced > Mode to Subtract. Use the Property pickwhip to create basic expressions linking the Start/End properties and anything else you find relevant. 
  • Whether the spacing is awful or passable depends heavily on the typeface you're using. I've typically found that adding another text animator (probably to the Bold version) for Tracking, and adjusting by 1-2 units is usually enough to make this work well enough. Depending on what else is happening in the template, giving the user the ability to make slight Position adjustments to the Bold version can also be helpful. 
  • If you need multiple instances of Bold within a single text block, you can add a second text animator (to both layers) to achieve this. 


While the above method isn't 100% perfect, I've used variants of this to create many highly-functional templates for many clients. Confirming exactly how the template will need to function, how long the text entries will typically be, etc. should usually allow you to design something that is functional enough without needing to over-engineer it. 

 

Suggestions for when the above doesn't quite get you there:

  • Add a Tracking property directly to your Opacity animators. Bold will typically require slightly more space than lighter weights, but you can compensate by specifically adjusting the Tracking only for the words being bolded.
  • If you need more font/weight options, you may want to actually want to create a "dummy" text layer that exists specifically to receive the user input from the template, which is then passed on to all your visible text layers. This opens you up to taking advantage of the text styling expressions, though that's a whole new can of worms!

 

Let me know if you need more direction on any of the above! Text animators are extremely powerful once you wrap your head around the (very different) way they work. 

 

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 ,
Mar 13, 2022 Mar 13, 2022

Copy link to clipboard

Copied

Hi Kyle,

Sorry for the late response and thanks for your help! The solution to solve the problem with the animator seemed pretty logical and nice to use. Unfortunately it didn’t work out with the font we had to use. Because the "Bold" typeface was using a lot more space than the "Light" one.
So we tried to solve our problem with code. As you are maybe interested how we did it. Here is the link to our AfterEffects file. (Its in german, but hopefully you can read it anyway)

https://we.tl/t-n5GD98Qey6

 

To summarize what we did is to write code where the words marked with "**" in front are displaying in bold.
We split the source text in seperate layers so we can attach each word to the previous one. We had to make two seperate layers, so we can create a "newStyle" in our main layer, that is displaying.

If you want to ad a new word, because your text needs more than 7 words, you can duplicate the layers 7 and name them 8. In our original template for the client, we just added 30 layers, so there is definitely enough words to fill.

We had to write some special code with the "-", so it recognised the words with a "-" as one word. A little buggy is the effect, that you have to make a "space" before making a line break, so you don’t get an error with the counting words.

In the "Effekteinstellungen" of "Start Position" you find some settings for expression like spacing of words and the position where the text start. In the "Dropdown-Menüsteuerung" you can switch if the text will write up- or downwards.

 

I hope you can maybe use this input in some of your projects soon. And thanks again for your help, I’m looking forward to make a template with the text animator.

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
Community Beginner ,
Mar 13, 2022 Mar 13, 2022

Copy link to clipboard

Copied

... ups I was logged in with the wrong account. Nevermind the message stays the same. 🙂

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
Community Expert ,
Mar 14, 2022 Mar 14, 2022

Copy link to clipboard

Copied

LATEST

Thanks for following up!

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