Activity › Forums › Adobe After Effects › Text box anchor point from baseline
-
Text box anchor point from baseline
Posted by Marko Suto on November 21, 2018 at 9:32 amHello AE experts ☺
I have a text box with dynamic input (from data file) that I bottom aligned using anchor point script (as I don’t know how many lines of text there will be):
[0,this.sourceRectAtTime(time).height]
But I need baseline align, not pixel align. Now, if there are “p,q,j,y” in the text, the layer will be lifted up by few pixels.
How to get the “sourceText.value.baselineLocs” or “textDocument.baselineLocs” in my script so they give me the position of the last line baseline (N-1)
Basicly something like this:
[0,this.sourceText.value.baselineLocs(N-1)]
Thanks!
Ilya Sire replied 3 years, 3 months ago 5 Members · 11 Replies -
11 Replies
-
Walter Soyka
November 21, 2018 at 12:01 pmI don’t know that there is a way to get the baseline, but you could use normal top alignment, measure the text, and insert line breaks as necessary to hit the target number of lines and force a bottom-alignment.
Attached, a project that demonstrates this with expressions. Put text into INPUT TEXT (which could be done programmatically, and which could be made invisibile), and observe the bottom alignment on in OUTPUT TEXT:
Walter Soyka
Designer & Mad Scientist at Keen Live [link]
Motion Graphics, Widescreen Events, Presentation Design, and Consulting
@keenlive | RenderBreak [blog] | Profile [LinkedIn] -
Marko Suto
November 21, 2018 at 1:50 pmThanks for the reply and link Walter!
I’m afraid I can’t open the project, it is done in a newer version of AE.
I have tried similar thing to your suggestion, used the iExpressions script for bottom align which does the job well – adds lines breaks on empty lines.
BUT it works only on point text, not box text. I need text box to limit the width of text.I tried to break the lines using VBA code in Excel (that’s where my source text is from – using CompsFromSpreadsheets script) with point text in AE, but my VBA script had problems with the width of the text (when I limit the max number of characters for one line, there’s a big difference in line full of “m” and “i” as far as width is concerned).
This “sourceText.value.baselineLocs”
https://helpx.adobe.com/uk/after-effects/using/creating-editing-text-layers.html
under “Scripts and expressions for working with text” section,
gave me hope I could use this array to get the Y position of the last line and use it as anchor point. But I don’t know how to define array and how to read the “N-1” value from the array. -
Walter Soyka
November 21, 2018 at 2:29 pm[Marko Suto] “This “sourceText.value.baselineLocs” https://helpx.adobe.com/uk/after-effects/using/creating-editing-text-layers... under “Scripts and expressions for working with text” section, gave me hope I could use this array to get the Y position of the last line and use it as anchor point. But I don’t know how to define array and how to read the “N-1″ value from the array.”
Nice! You’d do it like this:
// replace with a reference to your text layer
textLayer = app.project.item(1).layer("OUTPUT TEXT");// get the baselineLocs array, then peel off the last value
baselineLocs = textLayer.property("Text").property("Source Text").value.baselineLocs;
lastBaselineY = baselineLocs[baselineLocs.length-1];And here are the downsaved versions of the project I did earlier this morning:
12902_textbaseline.zip.zipWalter Soyka
Designer & Mad Scientist at Keen Live [link]
Motion Graphics, Widescreen Events, Presentation Design, and Consulting
@keenlive | RenderBreak [blog] | Profile [LinkedIn] -
Marko Suto
November 22, 2018 at 9:47 amCheers Walter!
Will give it a try as soon as I can (hopefully later today) and let you know how it worked!
-
Marko Suto
November 23, 2018 at 11:11 am -
Walter Soyka
November 23, 2018 at 12:15 pmScripts and expressions are different! I don’t think that the baselineLocs attribute is available to the expressions engine.
If you need an expressions-based system for this, please see the downsaved versions of the project file I posted earlier this week. It works on paragraphs/text boxes by inserting blank lines, and will help you bottom align arbitrary text on-the-fly.
Walter Soyka
Designer & Mad Scientist at Keen Live [link]
Motion Graphics, Widescreen Events, Presentation Design, and Consulting
@keenlive | RenderBreak [blog] | Profile [LinkedIn] -
Marko Suto
November 23, 2018 at 12:37 pmThanks for clarifying!
I have downloaded your downsaved files, will go through them now. -
Kalleheikki Kannisto
November 23, 2018 at 2:59 pmWhat I do is round the height result to the closest multiple of the line spacing, thus ignoring the differences caused by descenders.
Kalleheikki Kannisto
Senior Graphic Designer
Reply to this Discussion! Login or Sign Up