Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Text layer bounds expression problem

New Here ,
Jan 12, 2015 Jan 12, 2015

I was working on something with this, and funky stuff seems to happen when there's any lower case letter with a decender (qypj) the box acts kinda funny.

In this image[2] you can see I'm using it to center the anchor point, but the words on the left with the decenders think the text box is way bigger than it is or something and puts the anchor point up a bunch, also screwing up a beautiful set of expressions I had keeping those words in the boxes and doing all sorts of other exciting stuff.after effects.PNG

The expression: myTextLayer.sourceRectAtTime().height/2; 

(I'm only centering the y axis so pay no attention to the anchor point not being in the middle of the x axis)

This is the first time we've had this feature so maybe I'm missing something or it's a lil funky still? Any help would be appreciated!

TOPICS
Expressions
2.1K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Feb 27, 2015 Feb 27, 2015
LATEST

I just looked into this, and it turns out there is no issue with the expression or how it's calculating the size of the rectangle. The issue is the original value of the anchor point is not affected by descender characters. I am assuming the full expression you're using to get the new anchor point value is this:

x = value[0]+this.sourceRectAtTime(time).width/2;

y = value[1]-this.sourceRectAtTime(time).height/2;

[x, y]

If you type any word in After Effects that has a descender, you will notice that they descend below the original anchor point. As a result, your new anchor point is being calculated from the original anchor point value which does not lie at the bottom of your text box.

The problem with this expression is that sometimes the original anchor point lies at the bottom of the rectangle, and sometimes it lies about 15px above the bottom of the rectangle, which puts your new anchor point 15px above where it should be.

The fix is to base the new anchor point off of the text box, not the original anchor point. Use this expression for the anchor point:

x = this.sourceRectAtTime(time).left+this.sourceRectAtTime(time).width/2;

y = this.sourceRectAtTime(time).top+this.sourceRectAtTime(time).height/2;

[x, y]

and this for the position (if you want to keep the text at its original position):

x = value[0]+transform.anchorPoint[0];

y = value[1]+transform.anchorPoint[1];

[x, y]

This is, of course, thanks to Dan Ebberts' post:

Finding the edges of text and shape layers just got a lot easier : Adobe After Effects Expressions

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines