Skip to main content
June 11, 2020
Answered

Expressions - Any way to access the maximum height of single line text layer given a font and size?

  • June 11, 2020
  • 4 replies
  • 2682 views

Hi, I'm making a MOGRT with multiple text layers, each layer is 1 line of text. I want to give users ability to change the font size for each line, but when they're the same font size, I want them to be evenly spaced. Using the sourceRect height doesn't work since it changes if caps were used, if there is ascenders, etc., which makes the lines look uneven. Is there a way to access what the maximum size of the text layer WOULD be given an font and size?

This topic has been closed for replies.
Correct answer Mylenium

I don't think so. There's no way to access the actual em-box sizes and actual calculated kerning/ leading/ spacing. In that regard the Adobe type engine is a black box.

 

Mylenium

4 replies

Adobe Employee
December 11, 2023

@cpvoa Can you post a image of what you are trying to achieve - either here or in private mail.

 

I have a general interest in trying to reduce the number of hacks that people need to do to get text to layout the way they want and so am looking to collect data on real world use cases.

 

Thanks

Douglas Waterfall

After Effects Engineering

Participant
February 27, 2023

For anyone else coming here, i found this article helpful! Believe this answers the OP's question
https://motiondeveloper.com/blog/dealing-with-descenders

Dan Ebberts
Community Expert
Community Expert
June 11, 2020

There is a hack you can use in some circumstances. If you use an expression like this for the source text of your text layer:

 

time < 0 ? "m" : value

it will substitute a single lower case "m" for the text at "negative time" (which means it won't be visible). (If your source text already has an expression, you'll have to combine the two expressions.)

Then you can have sourceRectAtTime() acces the text's height at a negative time to get the height of the "m":

 

thisComp.layer("text").sourceRectAtTime(-1,false).height

 

Dan

 

cpvoaAuthor
June 11, 2020

That is a great hack! I'm worried about how it would work if it needs to allow multiple languages, but it's worth trying! Thanks!

Inspiring
June 11, 2020

Negative time expressions are useful for all sorts of things you wouldn't initially think are possible in AE's text engine. I've used them for measuring the dimensions of individual characters to map per-character effects to text and to measure individual words to automate a bouncing ball for singalong lyrics, for example.

Mylenium
MyleniumCorrect answer
Legend
June 11, 2020

I don't think so. There's no way to access the actual em-box sizes and actual calculated kerning/ leading/ spacing. In that regard the Adobe type engine is a black box.

 

Mylenium

cpvoaAuthor
June 11, 2020

Thanks, I think I will make every line follow the sourceRect height of the largest line, and then give them ability to adjust each line from there.