download Pins & Boxes
https://aescripts.com/pins-and-boxes/

Pins and Boxes is an automatic layout system for Adobe After Effects.
In this tutorial you learn how to ensure that a box always has at least a given minimum size – even if the text becomes smaller than that minimum size.
In Pins and Boxes, boxes are always based on pins. To create a box around some text layer, for example, you first attach some pins to the corners of a text and then you create a box that includes all those pins. The trick is to create some additional pins at the corners of the minimum area your box should have. For this we use pins which are not attached to any layer, so they always stay in place. Then you add those pins to your box such that the box always includes both this minimal area and the text. So effectively, the box grows when the text becomes bigger, but never shrinks below the minimal area you defined with the additional pins.