Hi John, try this:
1. Create a Null with 2 sliders called Total Width & Spacing, and apply the following expression to the Total Width slider:
const spacing = effect("Spacing")("Slider").value;
let totalWidth = 0;
let rectTime = time;
if (thisLayer.marker.numKeys) {
rectTime = thisLayer.marker.key(1).time;
}
for (let i = 1; i <= thisComp.numLayers; i++) {
const L = thisComp.layer(i);
if (L.hasParent && L.parent.index == thisLayer.index) {
totalWidth += L.sourceRectAtTime(rectTime).width + spacing;
}
}
totalWidth - spacing;
2. Make sure your text layers are left-aligned, parent them to the Null, and use the following code for your text layers’ position:
const spacing = parent.effect("Spacing")("Slider").value;
const totalWidth = parent.effect("Total Width")("Slider").value;
const center = thisComp.width / 2;
let x = center - (totalWidth / 2);
let rectTime = time;
if (parent.marker.numKeys) {
rectTime = parent.marker.key(1).time;
}
for (let i = thisComp.numLayers; i > index; i--) {
const L = thisComp.layer(i);
if (L.hasParent && L.parent.index == parent.index) {
x += L.sourceRectAtTime(rectTime).width + spacing;
}
}
parent.fromComp([x, parent.transform.position[1]]);
If you want to start a new line, you can create a new Null and parent all related text layers to that Null – then you can control the line spacing with your Nulls’ Y positions.
Regarding text animators, you can use a marker on the Null layer as the sampling time for the layout.
LMK if that works!