Please see my comment to the question. Sorry, but at this moment, I know only two solutions, but both are of low quality. There is a claim that accurate solution exist, but please see this:
The second solution is just quite awkward and would provide poorest performance, very likely prohibitively poor: draw the string on some bitmap starting with
x = 0
in contrast color, say, white on black, and then detect rightmost non-black pixel.
Sorry: so far, so bad. :-)