a way to create a default mask around the text, through script
To my knowledge, no way to get this rectangular default box.
I did a quick jump into the SDK guide a few months ago and found the syntax that returns the width of a text, something like
myTextWidth = in_data->extent_hint.right - in_data->extent_hint.left;
(the in_data pointer represents the layer)
I suppose vidpat has used something similar in his plugin. But this is based on the visible (alpha) part of the layer, so that it becames useless whenever the layer is outside the comp screen.
You may execute another app from ae in which you can determine 'easily' the text length in pixels (Lloyd has mentionned Illustrator, and I wrote a ae script for this that uses Photoshop..). But of course this solution is not always possible and not very 'clean'.
Anecdotical history: last year I was working on a project for a french national tv involving a lot of 'text management'. I have determined the width of approximately hundred characters and symbols one by one (with the rectangular mask tool and a script)....a real pain. Hopefully they use a single font ! I did it one time and include now this small database in all text-related scripts I write for them.