- FontRenderContext FRC = new FontRenderContext(new AffineTransform(), true, true);
- TextLayout tl = new TextLayout(text, font, FRC);
- Rectangle2D bounds = tl.getLogicalHighlightShape(0, text.length()).getBounds2D();
- size.setFrame(
- getAlignedXCoordinate(bounds, horizontalAlignment) * scale - paddingX,
- bounds.getY() * scale -paddingY,
- bounds.getWidth()* scale + paddingX + paddingX,
- bounds.getHeight()* scale + paddingY + paddingY);
+ TextNode n= new TextNode();
+ n.init(text, font, Color.black, 0.0, 0.0, scale);
+ n.setHorizontalAlignment((byte)horizontalAlignment.ordinal());
+ n.setVerticalAlignment((byte)verticalAlignment.ordinal());
+
+ Rectangle2D r = n.getBoundsInLocal();
+ size.setFrame(r);
+ return r;