This one is very difficult to solve.
Because box width are computed in Java using standard Java font.
And drawing is done by LaTeX using LaTeX font, which means that size does not match between both.
However, we've made few tests. We've written some heuristic which tries to guess how the font will size in LaTeX.
You can use beta 18 to check it:
Unfortunately the result will never be perfect here.
Tell us if it's somehow better!