Graphics

 View Only
  • 1.  Vertical Text Centering (Single or Group)

    Posted 01-08-2019 23:13

    Good evening,
    Has anybody successfully been able to get XPression to center text vertically correctly? I've looked through the forum and have tried the Text.BoundingBox.Height > Divide by 2 (or 2.5 - seen both here) > Text.Position.Y. It works to a point, but the text always ends up being offset too high. Ultimately what I'm looking to do is attached below - either 1 or 2 lines of text with different font weights (sizes are the same) and get them to be centered over the backplate. Each line of text can itself have multiple lines.

    I've tried various methods in visual logic, but nothing has worked so far.

    thanks in advance,
    Brian



  • 2.  RE: Vertical Text Centering (Single or Group)

    Posted 01-10-2019 18:38
    What does your visual logic look like currently that you're having the issue with trying to center it?

    The thing that sticks out to me is why you may need any sort of logic to vertically align it, is something happening to the quad that changes its dimensions that you'd need to dynamically center it? Even then changing the quad height in pixel height or even scaling would do so from its pivot point (defaulted to the center) and would keep the text still appear centered vertically if placed by hand.

    Is it that the TOPIC 1 HERE text object will need to, at some point, go to 2 or more lines?
    #XPression


  • 3.  RE: Vertical Text Centering (Single or Group)

    Posted 01-10-2019 19:01

    Hello Brian,

    by default , the pivot point of a text is align to his baseline : that may explain why your text is offsetted not the way you want.
    You can manually adjust the pivot to match the top of your text :

    With this done, height/2 logic should work fine :



    Then you can extend your logic to take into account 2 texts .The second text is offsetted by the height of the first text :

    see sample project attached : TYT_Vertical_align_001.zip

    hope it helps.


    #XPression


  • 4.  RE: Vertical Text Centering (Single or Group)

    Posted 01-14-2019 03:27
    Thanks for your responses. I figured it out - sort of. I still had to add some positioning elements in my visual logic to handle Y positioning. The key I found is having the text scaling set to 1.0 on each text element, and handling any scaling I needed to do in a parent group (or groups). It's not as pretty or simple as I would like it to be, but it is working. I'll post a sample in this thread soon so you can see my workaround.
    #XPression