Skip to main content
brandonb96942845
Inspiring
April 22, 2023
Question

SourceRectAtTime: Tell AfterEffects to ignore hanging parts of letters (Ps, Gs, Ys, commas, etc.)

  • April 22, 2023
  • 1 reply
  • 1052 views

I've come across another one of those would-be-nice kinds of situations, and I haven't been able to find anything about this on Google so this may not be something anybody else has tried to do--but when doing a SourceRectAtTime for the height of a text layer, is there any way to tell it to ignore the hanging parts of letters and punctuation? Things like parentheses, commas, and some lower-case letters like y's, p's, g's, and so on can throw off the height calculation.

 

(And for that matter it can throw off the leading between lines, which is something else I'd really love to be able to address)

 

I know some other software is capable of saying "if the capitol of this matches the capitol of that," and I'm curious if it's possible to do something similar with AE--maintain consistent spacing based on letters only (and then to look at capitals instead of mixed-case), and ignore any punctuation marks completely?

 

The specific usage scenario I have where this would come into play--I've got an end credits sequence where instead of scrolling, the credits just pop in one right after the other, and anytime there's a comma, or a parenthesis, or a slash for a URL, or a mixed-case letter with a hanging element, it throws off the spacing and there's a visible difference in position from one to the next. It's a minor annoyance at best, but it's "one of those things."

 

I can think of a couple of very complicated ways to overcome this, so it's not like it's an unsolvable problem, but I'd like to know if there's a simpler way to go about it than what I'm thinking of.

This topic has been closed for replies.

1 reply

Community Expert
April 22, 2023

sourceRectAtTime() always measures the height and width of a layer. With text and shape layers, you get the top and left positions, also.

 

If you want lines to pip up to the same height, you have to use Position and make sure that the baseline shift is the same for every layer.

 

For end-line credits to pop up to the same line, one after another, you can just use a simple expression that starts a move based on layer in-point minus time, then sequence multiple text layers. If you want to use multiple text layers, you can offset the position and time based on the layer index. 

 

If you put all of your lines of text on a single line, you can adjust the leading and create an expression that moves up and pauses based on time. A couple of sliders, one for the duration of the move and one for the duration of the pause and some time - inPoint would do the trick. 

 

I probably have a hundred animation presets that I made for moving text, layers, and graphics automatically. None of them use keyframes. they all use a variation of ease(t, tMin, tMax, Value1, Value2) and a couple of sliders to do the trick.

 

 

Adam24585301qycn
Inspiring
April 24, 2023

posterizeTime(0);
function getNumRows(myLeading, myFontSize, height) {
H = height - myFontSize * 0.5;
return Math.floor(H / myLeading);
}
H = sourceRectAtTime(time, false).height;
var myStyle = text.sourceText.style;
myFontSize = myStyle.fontSize;
myLeading = myStyle.autoLeading ? myFontSize * 1.15 : myStyle.leading;
numRows = getNumRows(myLeading, myFontSize, H);
S = scale[1] * 0.01;
value + [0, numRows * myLeading * S];

 

 

Adam24585301qycn
Inspiring
April 24, 2023

I believe you need to set your anchor point to the bottom before you apply it.