Hey Paul,
the entire setup is made so that we want to know the size of individual characters of the text.
There’s no built-in method to do this, you can only get the sourceRectAtTime() of the entire text-layer. But what if at certain points in Time, just one character is visible, then getting the sourceRect of the layer would be the sourceRect of that character.
Imagine that we would make a copy of our text layer and at time 1: character 1 is visibile, at time 2: character 2 is visible etc.
We would need a subtractive range selector from 0-1, animating its offset by “time”. That range should set all (non selected) characters’ scales to 0% (because setting the opacity to 0% does not remove characters from the bounding box rect).
That would work, but we would need a second copy of the layer. So why not do it in the same layer, but at a different time than we use visibly in the composition. We could do that at time +100000 seconds and suppose we’ll never use that part of the layer, or we could use negative time: layers and source of layers can perfectly exist before the start of out composition, so why not.
I choose -100 seconds as a starting point instead of 0, just as a buffer. (expression on offset)
So, if the time is not negative, and hence visible and used int he composition, the range scaling all the characters down should just be not be active (expression on amount switching it to 0). but it’s a subtractive range, so we have to change the mode to a ‘normal’ additive range when it’s not active (expression on mode switching between mode 2 and mode 1) otherwise everything would be “not not” selected and scaled
OK, so now we can examine the position, width and height of each individual character (at time -101 for character 1, -102 for character 2,…) , but we don’t want the cursor to be vertically aligned to the shape of each character, otherwise the cursor would be a few pixels lower when next to a “p” than when next to a “Á” character. So we use an extra text animator, to change all the characters to 1 uniform shape, again only in negative time, using the character value property, it will change ” sample text ” to ” xxxxx xxxx ” while keeping the kerning of the original, but it ignores spaces, which is why we need an epxression on sourceText to change regular spaces to special spaces which that animator does change into a character. Because otherwise, the sourceRect of ” ” is of course 0,0,0,0.
I hope that gives some insights