// Reference the text layer
subText = thisComp.layer("TEXT");
// Target text layer
// Get text dimensions
textWidth = subText.sourceRectAtTime(time, false).width + 70;
textHeight = subText.sourceRectAtTime(time, false).height + 70;
prop = thisProperty;
// Keyframed animation range
firstValue = prop.key(1).value[0];
// Starting width from first keyframe
lastValue = prop.key(2).value[0];
// Ending width from second keyframe
// Final width based on text
newWidth = textWidth;
animatedWidth = linear(value[0], firstValue, lastValue, firstValue, newWidth);
[animatedWidth, textHeight];