Browse Source

The last change neglected the first character which
has special treatment for its x0 setting but still
requires that the xAdvance be adjusted to account
for accumulated xOffset.


git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@8473 75d07b2b-3a1a-0410-a2c5-0572b91ccdca

PSp..om 14 years ago
parent
commit
68c2fea479
1 changed files with 12 additions and 0 deletions
  1. 12 0
      engine/src/core/com/jme3/font/LetterQuad.java

+ 12 - 0
engine/src/core/com/jme3/font/LetterQuad.java

@@ -291,6 +291,18 @@ class LetterQuad {
 
             if (previous.isHead() || previous.eol) {
                 x0 = bound.x;
+                
+                // The first letter quad will be drawn right at the first
+                // position... but it does not offset by the characters offset
+                // amount.  This means that we've potentially accumulated extra
+                // pixels and the next letter won't get drawn far enough unless
+                // we add this offset back into xAdvance.. by subtracting it.
+                // This is the same thing that's done below because we've
+                // technically baked the offset in just like below.  It doesn't
+                // look like it at first glance so I'm keeping it separate with
+                // this comment.
+                xAdvance -= xOffset * incrScale; 
+                
             } else {
                 x0 = previous.getNextX() + xOffset * incrScale;