Forums › Adobe After Effects Expressions › Text building upwards and ignoring descenders
-
Text building upwards and ignoring descenders
-
Adam Greenberg
September 13, 2021 at 5:22 pmHi everyone. I already know how to add an expression that will build the multilines upwards. ( meaning if i have 3 lines of text, the last line would appear in the exact same Y position as if I had 1 line of text. )
But in this case, I have a font that has descenders. like the letter p for example, which breaks my alignment if this letter appears in the last line of text. I am looking for a way to edit the postition expression of my text that will keep the baseline of the last line at the correct place.
Currently it appears that if I have descenders only on the higher lines, it still works.
The expression I am using does seem to ignore the ascenders, which is great, and also keeps the proper distance between the lines regardless of ascenders and descenders which is also great. So its quite frustrating to be 99% of the way there.
this is the current expression
transform.position – [0, thisLayer.sourceRectAtTime().height]
Thanks so much
-
Andrei Popa
September 13, 2021 at 5:42 pmIs that a paragraph text or a point text? Meaning, are the rows broken with “Enter” or are they auto by the borders of the paragraph text?
If paragraph text:
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.2 : myStyle.leading;
numRows = getNumRows(myLeading, myFontSize, H);
S = scale[1] * 0.01;
value - [0, numRows * myLeading * S];If point text:
var myStyle = text.sourceText.style;
myFontSize = myStyle.fontSize;
myLeading = myStyle.autoLeading ? myFontSize * 1.2 : myStyle.leading;
S = scale[1] * 0.01;1
numRows = text.sourceText.split("\r").length;
value - [0, numRows * myLeading * S]; -
Adam Greenberg
September 13, 2021 at 5:55 pm -
Adam Greenberg
September 13, 2021 at 7:32 pmif i switch off of legacy, and pick regular javascript then it works, but everytime the text has another line added, it keeps going lower and lower. I need the last line of text to be in the same place. So the text need to go up everytime we add a line.
-
Fabrice Leconte
September 13, 2021 at 7:44 pmAt line 4, you need to return a negative value:
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.2 : myStyle.leading;
numRows = getNumRows(myLeading, myFontSize, H);
S = scale[1] * 0.01;
value - [0, numRows * -myLeading * S];
-
Adam Greenberg
September 13, 2021 at 8:17 pmOh I had to set my anchor point at the bottom. Forgot about that.
THANKS sooooo much.
But does anyone have any advice for me as far as the java script setting goes. Id like it to work in legacy extended script if possible.
Log in to reply.