This is not a solution but a workaround. What I did was to simply mask the shape layer to get cropped on the left side (or whichever side you wish). I also repositioned the shape so its center was on top of the beginning of the editable text.
I changed the code a bit as well to match my design:
I’m trying to use this code for a text layer for subtitles, so as the voiceover changes, I have another text keyframe and I’d like the box to adjust as the text changes in width. Seems like the code only is seeing the last keyframe text width size. I’m assuming this is because the code doesn’t execute every time there is a new keyframe…is there a way to do this?
.style just looks at the fontSize of the very first Character, so if for some layout-reason that character was set at a smaller size and you want to look at a different character, you should use this:
textSize = t.text.sourceText.getStyleAt(1).fontSize;
the index is 0-based, so this example will look at the fontSize of the second character.