xmlgraphics-batik-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Eugene Ogryzlo <eugco...@gmail.com>
Subject [No Subject]
Date Tue, 26 Feb 2013 08:44:25 GMT

I need to paint caret for editing text on JSVGCanvas. I haven't found
method getCaretShape() in batik, so I'm using java.awt.font.TextLayout. It
is how I do it:

// family, style, size I get from DOM
Font font = new Font(family, style, size);
TextLayout textLayout = new TextLayout(text, font, new
FontRenderContext(new AffineTransform(), true, false));

// Mark is calculated correctly by TextPainter.selectAt
Shape caret = textLayout.getCaretShapes(mark.getCharIndex())[0];

// x and y are textnode's coordinates
AffineTransform at = new AffineTransform();
at.translate(x, y);
caret = at.createTransformedShape(shape);

Caret is calculated incorrectly. It has some error. I'm sure batik has
another solution. How can I solve this problem?

View raw message