NT Productions shows how to create a script that will auto-fit type to any designated width in After Effects.
Auto-Scale as You Type.
The script will automatically scale text layers in After Effects based on a custom width and height that you set. It will also inject an expression that allows you to customize almost anything.
There are a few tools that allow you to auto-fit type, especially along with graphic boundaries. There are lots of plugins and techniques that cover creating auto-adjusting type layers and graphics in combination.