I'm having big problems bounding() in Java2d with LineBreakMeasurer.
Anyone have any ideas? The Rectangle drawn doesn't sit on the string like it should. The bounds method normally works ok. I think its maybe this bug..


Anyone able to code me a workaround to this please?
Font font = new Font(layMod.getBotName_fontName(), layMod.getBotName_fontWeight(),
FontRenderContext frc= g2d.getFontRenderContext();
TextLayout layout = new TextLayout("Some text", font, frc);
AttributedString astr = new AttributedString("Some text");
astr.addAttribute(TextAttribute.FONT, font);
AttributedCharacterIterator paragraph = astr.getIterator();
frc = g2d.getFontRenderContext();
LineBreakMeasurer lineMeasurer = new LineBreakMeasurer(paragraph, new FontRenderContext(null, false, false));
int paragraphStart = paragraph.getBeginIndex();
int paragraphEnd = paragraph.getEndIndex();
Dimension size = r2d.getBounds().getSize();
float formatWidth = (float) size.width;
float drawPosY = layMod.getBotName_y_position()*scalar;
while (lineMeasurer.getPosition() < paragraphEnd) {
layout = lineMeasurer.nextLayout(formatWidth);
drawPosY += layout.getAscent();
float drawPosX;
if (layout.isLeftToRight()) {
drawPosX = layMod.getBotName_x_position()*scalar;
else {
drawPosX = formatWidth - layout.getAdvance();
layout.draw(g2d, drawPosX, drawPosY);
drawPosY += layout.getDescent() +