Welcome Dialog

Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.


How is the Anchor Point of text layer calculated

Explorer ,
Aug 01, 2018 Aug 01, 2018

Copy link to clipboard

Copied

Hi,

I am just wondering how the anchor point of a text layer is calculated. I have reseted my character and paragraph panel and typing out a text "jewelry" (in Times New Roman because that is the Default) and no matter how I align the text with the paragraph tool the Anchor Point at [0,0] never touches the bounding box of the text layer.

So is it known how these x and y coordinates are calculated or where the origin is based?

Kind regards

Christian

Views

1.3K

Likes

Translate

Translate

Report

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

correct answers 1 Correct answer

Adobe Community Professional , Aug 01, 2018 Aug 01, 2018
To clarify, are you using paragraph text, or point text? (drag a box vs click) While many things work the same, paragraph text can come with a few extra complications. You've got a variety of functions available to you using sourceRectAtTime, which should allow you to get what you need.For example, adding this expression to the text layer's Anchor Point will keep it centered on the bounding box, observing multiple lines,  line spacing, ascenders/decenders, strokes, etc. var rect = thisLayer.sour...

Likes

Translate

Translate
Adobe Community Professional ,
Aug 01, 2018 Aug 01, 2018

Copy link to clipboard

Copied

Text operates based on the em box of each individual letter, meaning the data that defines spacing, leading and kerning, not just the visible data. Has never worked any different. Also AE honors the alignment setting of the text paragraph, so coordinates of 0,0 can still be in the center of the text, if only is set to centered alignment.

Mylenium

Likes

Translate

Translate

Report

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
Explorer ,
Aug 01, 2018 Aug 01, 2018

Copy link to clipboard

Copied

So how can I than callculate the center of a text layer is there a way to access the data of these boxes around all letters?

I want to dynamically change the center of the text layer, without having to use a script to recenter the anchor point after every change. Is this possible?

Likes

Translate

Translate

Report

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
Adobe Community Professional ,
Aug 01, 2018 Aug 01, 2018

Copy link to clipboard

Copied

That's what the sourceRectAtTime() expression is for, though ironically it is based on the rasterized pixel data, so you may still need to build in extra offsets to get your anchor point to appear where you want it. The "visual center" still would not necessarily be the absolute center.

Mylenium

Likes

Translate

Translate

Report

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
Explorer ,
Aug 01, 2018 Aug 01, 2018

Copy link to clipboard

Copied

Thanks for your help. I have tried it already with the sourceRectAtTime() but it hasn't given me the center of the text layer, because the anchor point doesn't unfortunately start in any of the corners. And with any change to the text the offset values change as well.

anchorPoint_text.JPG

Is there a way to get the center of the red bounding box? Or is there a way to fetch those additionally needed offset data to use in an expression?

Christian

Likes

Translate

Translate

Report

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
Adobe Community Professional ,
Aug 01, 2018 Aug 01, 2018

Copy link to clipboard

Copied

To clarify, are you using paragraph text, or point text? (drag a box vs click)
While many things work the same, paragraph text can come with a few extra complications.


You've got a variety of functions available to you using sourceRectAtTime, which should allow you to get what you need.

For example, adding this expression to the text layer's Anchor Point will keep it centered on the bounding box, observing multiple lines,  line spacing, ascenders/decenders, strokes, etc.

var rect = thisLayer.sourceRectAtTime();

var x = rect.left+rect.width/2;

var y = rect.top+rect.height/2;

[x,y]

Likes

Translate

Translate

Report

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
Explorer ,
Aug 02, 2018 Aug 02, 2018

Copy link to clipboard

Copied

Thank you this works perfectly with point text.

Likes

Translate

Translate

Report

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
New Here ,
May 06, 2021 May 06, 2021

Copy link to clipboard

Copied

Thats great! I was wondering if theres a way to deal with the upper or lower length of letters - like f or g ... or ascender, descender of the letters. The thing im trying is to have the same anchorpoint for words with or without upper or lower length. Basically im trying to get the same centerpoint even it the word is assymetrical in Height.
For example "man" , "Man", "song" or "Song"

Likes

Translate

Translate

Report

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
Adobe Community Professional ,
May 06, 2021 May 06, 2021

Copy link to clipboard

Copied

LATEST

Here is how text layers work:

  • The default anchor point for a text layer always at 0,0
  • The actual text is either left justified, right justified, or centered 
  • The position of the text is always relative to the baseline. If the baseline shift is -100 then the bottom of the first line of text will always be 100 pixels above the baseline
  • Unless you reset the anchor point, the baseline will always be in the same position as the Anchor Point vertically and the anchor point will be at the left edge of text left-justified, in the center of text center-justified, and on the right edge of the text layer if the text is right-justified
  • sourceRectAtTime().top always measures from the baseline to the top of the text area
  • sourceRectAtTime().left always measures from the anchor point's default X value of zero to the left edge of the text.
  • If you move the anchor point from the default value of [ 0, 0] you will have to compensate for that movement in any expression using sourceRectAtTime()

The following expression will always center a shape layer Rectangle/Position behind a text layer that is above it no matter what the justification as long as the position of the text layer is tied to the position of the text layer and the anchor point of the text layer and the shape layer is at the default [0, 0]value:

src=thisComp.layer(index - 1);
box = sRc.sourceRectAtTime();
refScale = sRc.scale * .01;
x = box.width / 2;
y = box.height / 2;
t = box.top;
l = box.left;

[(x + l) * refScale[0], (y + t) * refScale[1]]

I hope that clears up the confusion. 

 

If you want to change the text layer's anchor point and keep a text box below it lined up you just have to tie both the position and the anchor point of the shape layer to the position and anchor point of the text layer with an expression.

magic text box.png

Likes

Translate

Translate

Report

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