Maintain vertical distance between text layers (each line with a bounding box)
I'm making a template for an adjustable lettering with a bounding box for each line. I'm almost done, but there's a final issue I just can't wrap my head around.
I'm trying to use sourceRectAtTime to autosize the boxes and automatically distribute the layers vertically. Here's my setup:
The box shape layers sizes are working fine (It's just like the Jake Barlett tutorial):
- Size property:
var s = thisComp.layer("txt 1");
var w = s.sourceRectAtTime().width + effect("Ajuste W")("Slider");
var h = s.sourceRectAtTime(3).height + effect("Ajuste H")("Slider");
[w,h]
- Position property:
var s = thisComp.layer("txt 1");
var w = s.sourceRectAtTime().width/2;
var h = s.sourceRectAtTime(3).height/2;
var l = s.sourceRectAtTime(3).left;
var t = s.sourceRectAtTime(3).top;
[w+l,h+t]
This works fine most of the time, but in Brazil we speak portuguese and there's a lot of accents: ´`^~. If there's an accent on a capital letter (Á, Ô, etc), the distances just don't stay the same.
Here's what I tried to fix that:
I parented the boxes to each text layer, then I applied this expression to the position property of the text layers:
var src=thisComp.layer(index + 1);
var src2 = thisLayer;
var srcHeight = src.sourceRectAtTime(3).height;
var src2Top = src2.sourceRectAtTime(3).top;
var pad = thisComp.layer("ctrl").effect("entrelinhas")("Slider") // distance between layers
var newY = srcHeight - src2Top + pad;
var strtPos = src.position;
[strtPos[0], strtPos[1] + newY]
This last part is not working as I wanted. The distances between lines don’t stay constant. Only if there’d be an accented capital letter on each of the lines. Unfortunately that’s not what’d happen. Here are some screenshots of the problem:





