Hey Dean, I think this might help you:
For both text layers add this expression for anchor point:
var rect = thisLayer.sourceRectAtTime();
[rect.left + rect.width / 2, rect.top + rect.height / 2];
For the top layer add this expression to its position:
var bottomText = thisComp.layer("Bottom Text"); // Replace with the actual name of the bottom text layer
var topRect = thisLayer.sourceRectAtTime();
var bottomRect = bottomText.sourceRectAtTime();
var maxWidth = Math.max(topRect.width, bottomRect.width); // Get the larger width
var x = thisComp.width / 2 + maxWidth / 2 - topRect.width / 2; // Align the right edge
var y = thisComp.height / 2 - topRect.height / 2 - 25; // Position vertically
[x, y];
For the bottom layer, add this expression to its position:
var topText = thisComp.layer("Top Text"); // Replace with the actual name of the top text layer
var topRect = topText.sourceRectAtTime();
var bottomRect = thisLayer.sourceRectAtTime();
var maxWidth = Math.max(topRect.width, bottomRect.width); // Get the larger width
var x = thisComp.width / 2 + maxWidth / 2 - bottomRect.width / 2; // Align the right edge
var y = topText.position[1] + (topRect.height / 2) + (bottomRect.height / 2) + 50; // Position below the top text
[x, y];
This setup dynamically aligns the two text layers as a right-aligned block, ensuring the entire block is centered horizontally based on the larger width of the layers while maintaining proper spacing between them.
I’m including me after effects file also if it can help you !