Nothing stops you from assigning a fixed value inside your expressions instead of your variables. Simply use e.g. [200,t-o] or whatever those values actually are.
But I don't think that solves the problem.
The height still varies depending on the type of letter I enter .Also, if I then want to scale the text the box won't scale with it.
sourceRectAtTime takes into account ascending and descending characters, font size differences and a bunch of other things. It also will read the size of a text box or text area that you draw. If you need the height of the box to stay the same just define the Y value in your expression.
If you want to make everything scale then you need to add a reference the scale value of the layer or the scale value of a text animator.
I can't seem to get it to work. If i fix the height the box then shifts when i enter new text.
What do you mean it shifts when you enter new text? I mean, it is expected that the size will change.
What does your expression on the box's position look like?
I created one couple of weeks ago
Note (expressions are universalized)
used this for POSITION :
content("Rectangle 1").content("Rectangle Path 1").size/2
t = thisComp.layer("Centered Text SC");
tRect = t.sourceRectAtTime(time,false);
tUL = t.toComp([tRect.left,tRect.top]);
tLR = t.toComp([tRect.left+tRect.width,tRect.top+tRect.height]);
tCenter = (tUL + tLR)/2
myRect = sourceRectAtTime(time,false);
myUL = toComp([myRect.left,myRect.top]);
myLR = toComp([myRect.left+myRect.width,myRect.top+myRect.height]);
myCenter = (myUL + myLR)/2
delta = myCenter - tCenter;
value - delta
and this for SIZE :
s = thisComp.layer("Centered Text SC");
thePadding = thisComp.layer("Controller").effect("Padding-Space")("ADBE Slider Control-0001");
x = s.sourceRectAtTime(time-s.inPoint,true).width +(thePadding*2)+thisComp.layer("Controller").effect("left-Right-Space")("ADBE Slider Control-0001") ;
y = s.sourceRectAtTime(time-s.inPoint,true).height +(thePadding*2)+thisComp.layer("Controller").effect("Top-Bottom--Space")("ADBE Slider Control-0001") ;
Thanks .I will give this a try .
Does this work for accented letters then, like in my example above?
I guess for the accented letters there must be something like the Math.round
for decimal numbers, but I really don't know. Check Dan Ebberts