I quickly did a sourceRect on a text-layer, and watched what the numbers did when I changed alignment, and it made sense: left aligned text starts at around 0,0, center aligned puts the center at 0,0 (so left ends up in the negative range) and right aligned puts the right edge at 0,0 (so the left edge would be at -width)
Then it clicked that the left/width ratio would give something around 0, -0.5, -1
Depending on the font design there’s quite some margin of error, so I rounded and clamped. And multiplied by -2 to get 0,1,2 for the three options.
I’m pretty sure there are outlier cases (maybe with very thin fonts, very short words,…) where this breaks