xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thomas Palfray <thomas.palf...@gmail.com>
Subject Define String Width with bounding box
Date Wed, 29 Oct 2008 14:59:07 GMT
Hi all,

I'm trying to find the width of a String, but i've a little problem.
in fact, i use getBBox() to find it, and it works ... but not in one case.

I have two test String :

"blabla bla"
"blabla bla "
getBBox() gives me the same length for the two String. It seems that it 
doesn't take the last blankspace.

Here is my method :
    private int getSVGStringWidth(String string, int fontSize){
        Element retourLigne = (Element)docCalcul.createElementNS(svgNS, 
        retourLigne.setAttributeNS(null,"x", "0");
        retourLigne.setAttributeNS(null,"y", "0");
        retourLigne.setAttributeNS(null,"font-family", "Verdana");
        Text tmpText = docCalcul.createTextNode(string);
        int retour = (int)((SVGLocatable)retourLigne).getBBox().getWidth();

        return retour;           
If someone have some advice, it could help me :)

To unsubscribe, e-mail: batik-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: batik-users-help@xmlgraphics.apache.org

View raw message