FORUMS: list search recent posts

Text box anchor point from baseline

COW Forums : Adobe After Effects

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Marko Suto
Text box anchor point from baseline
on Nov 21, 2018 at 9:32:53 am

Hello 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!


Return to posts index

Walter Soyka
Re: Text box anchor point from baseline
on Nov 21, 2018 at 12:01:31 pm

I 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:

12901_textbaseline.aep.zip

Walter Soyka
Designer & Mad Scientist at Keen Live [link]
Motion Graphics, Widescreen Events, Presentation Design, and Consulting
@keenlive [twitter]   |   RenderBreak [blog]   |   Profile [LinkedIn]


Return to posts index

Marko Suto
Re: Text box anchor point from baseline
on Nov 21, 2018 at 1:50:07 pm

Thanks 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...

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.


Return to posts index


Walter Soyka
Re: Text box anchor point from baseline
on Nov 21, 2018 at 2:29:15 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.zip

Walter Soyka
Designer & Mad Scientist at Keen Live [link]
Motion Graphics, Widescreen Events, Presentation Design, and Consulting
@keenlive [twitter]   |   RenderBreak [blog]   |   Profile [LinkedIn]


Return to posts index

Marko Suto
Re: Text box anchor point from baseline
on Nov 22, 2018 at 9:47:38 am

Cheers Walter!

Will give it a try as soon as I can (hopefully later today) and let you know how it worked!


Return to posts index

Marko Suto
Re: Text box anchor point from baseline
on Nov 23, 2018 at 11:11:57 am

I've tried the above mentioned, but I can't get it to work.
As before, I've tried to enter the code in Anchor point expression, but I don't know how to refer to the project item...


Return to posts index


Walter Soyka
Re: Text box anchor point from baseline
on Nov 23, 2018 at 12:15:04 pm

Scripts 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 [twitter]   |   RenderBreak [blog]   |   Profile [LinkedIn]


Return to posts index

Marko Suto
Re: Text box anchor point from baseline
on Nov 23, 2018 at 12:37:22 pm

Thanks for clarifying!
I have downloaded your downsaved files, will go through them now.


Return to posts index

Marko Suto
Re: Text box anchor point from baseline
on Nov 23, 2018 at 2:46:40 pm

Works like a charm, many thanks for all the effort!!!


Return to posts index


Kalleheikki Kannisto
Re: Text box anchor point from baseline
on Nov 23, 2018 at 2:59:45 pm

What 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


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2018 CreativeCOW.net All Rights Reserved
[TOP]