Initial merge into juju repository

This PR is the initial merge of previous work into the juju/jujusvg repository.
I think this would be more readable if you defined minInt and maxInt constants outside the function.