Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity › Forums › Adobe After Effects Expressions › Auto centre text on y to shape layer while ignoring any accents

  • Auto centre text on y to shape layer while ignoring any accents

    Posted by Jun Iwakawa on February 18, 2022 at 6:25 pm

    Hi there,

    I’ve been trying to build a rig for centre-aligned text (All in CAPs) to automatically centre to a shape layer. It also needs to work for 2x lined text, so if I hit return to add a second line, it adjusts to remain vertically centred to the shape (while the shape height remains fixed).

     

    I applied this expression to the anchor point of the text layer:

    s=sourceRectAtTime();[0,s.top+s.height/2]+value;

     

    And used this expression to the size of the shape layer:

    s=thisComp.layer(“TypeLayerA”);

    x=s.sourceRectAtTime(time-s.inPoint,true).width+100;

    y=s.height=233;

    [x,y]

     

    It all works fine until a word has an accent, at which point the expression used to centre the text on the ‘y’ factors in the additional height attributed to the accent. This results in the baseline of the text shifting vertically out of place.

    Is there a way to either factor this in (not sure if there’s an if/else type solution for this) OR a way to dismiss all accents? It also has to ignore lower hanging accents e.g. cedillas.

     

    Any help hugely appreciated!

    Filip Vandueren replied 4 years, 7 months ago 2 Members · 1 Reply
  • 1 Reply
  • Filip Vandueren

    February 19, 2022 at 12:42 pm

    add a “|” symbol to the start and end of the text and make it invisible using an opacity animator.

    It will still count as a part of the sourceRect, and the pipe symbol in most fonts spans the height from ascender to descender, unless you’re using double accents such as ǻ in which case, try to find a character in your font that does reach high enough, or even use 2 characters, but the advantage of a | is that it hardly shifts the layout of a centered paragraph.

    Lastly, there’s always the option to hack the font and add a special character that you’re sure has the right vertical span and is extremely thin and takes up no kerning space.

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy