diff --git a/engine/src/core/com/jme3/font/LetterQuad.java b/engine/src/core/com/jme3/font/LetterQuad.java index edb3f5308..bf4b082bb 100644 --- a/engine/src/core/com/jme3/font/LetterQuad.java +++ b/engine/src/core/com/jme3/font/LetterQuad.java @@ -293,6 +293,15 @@ class LetterQuad { x0 = bound.x; } else { x0 = previous.getNextX() + xOffset * incrScale; + + // Since x0 will have offset baked into it then we + // need to counteract that in xAdvance. This is better + // than removing it in getNextX() because we also need + // to take kerning into account below... which will also + // get baked in. + // Without this, getNextX() will return values too far to + // the left, for example. + xAdvance -= xOffset * incrScale; } y0 = lineY + LINE_DIR*yOffset; @@ -301,6 +310,10 @@ class LetterQuad { if (lastChar != null && block.isKerning()) { kernAmount = lastChar.getKerning(c) * sizeScale; x0 += kernAmount * incrScale; + + // Need to unbake the kerning from xAdvance since it + // is baked into x0... see above. + xAdvance -= kernAmount * incrScale; } } if (isEndOfLine()) { diff --git a/engine/src/core/com/jme3/font/Letters.java b/engine/src/core/com/jme3/font/Letters.java index 198c4974b..34cd7dc4b 100644 --- a/engine/src/core/com/jme3/font/Letters.java +++ b/engine/src/core/com/jme3/font/Letters.java @@ -77,7 +77,7 @@ class Letters { int lineCount = 1; BitmapCharacter ellipsis = font.getCharSet().getCharacter(block.getEllipsisChar()); float ellipsisWidth = ellipsis!=null? ellipsis.getWidth()*getScale(): 0; - + while (!l.isTail()) { if (l.isInvalid()) { l.update(block);