Highlighted

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

Community Beginner ,
Jun 11, 2020

Copy link to clipboard

Copied

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?

Most Valuable Participant
Correct answer by Mylenium | Most Valuable Participant

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

Topics

Expressions, How to

Views

220

Likes

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

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

Community Beginner ,
Jun 11, 2020

Copy link to clipboard

Copied

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?

Most Valuable Participant
Correct answer by Mylenium | Most Valuable Participant

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

Topics

Expressions, How to

Views

221

Likes

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
Most Valuable Participant ,
Jun 11, 2020

Copy link to clipboard

Copied

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

Likes

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
Reply
Loading...
Community Beginner ,
Jun 11, 2020

Copy link to clipboard

Copied

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. 

Likes

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
Reply
Loading...
Guide ,
Jun 11, 2020

Copy link to clipboard

Copied

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

 

Likes

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
Reply
Loading...
Community Beginner ,
Jun 11, 2020

Copy link to clipboard

Copied

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!

Likes

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
Reply
Loading...
A__Cobb LATEST
Enthusiast ,
Jun 11, 2020

Copy link to clipboard

Copied

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.

Likes

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
Reply
Loading...