Fixed some really odd text advance behavior that

caused letters and characters to overlap each other.
Basically, the offset was being included in the next
chars position... and it shouldn't be.


git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@8472 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
PSp..om 13 years ago
parent 97145d7d4d
commit ee2f44f340
  1. 13
      engine/src/core/com/jme3/font/LetterQuad.java

@ -293,6 +293,15 @@ class LetterQuad {
x0 = bound.x; x0 = bound.x;
} else { } else {
x0 = previous.getNextX() + xOffset * incrScale; 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; y0 = lineY + LINE_DIR*yOffset;
@ -301,6 +310,10 @@ class LetterQuad {
if (lastChar != null && block.isKerning()) { if (lastChar != null && block.isKerning()) {
kernAmount = lastChar.getKerning(c) * sizeScale; kernAmount = lastChar.getKerning(c) * sizeScale;
x0 += kernAmount * incrScale; x0 += kernAmount * incrScale;
// Need to unbake the kerning from xAdvance since it
// is baked into x0... see above.
xAdvance -= kernAmount * incrScale;
} }
} }
if (isEndOfLine()) { if (isEndOfLine()) {

Loading…
Cancel
Save