BitmapCharacter.getKerning() currently returns -1 if there is no kerning pair defined. This makes it impossible to distinguish from the common case of a real kerning pair with a value of -1. This patch makes it return 0 instead, i.e. no kerning. Functions in core that call this method have been updated to suit.
Fixes issue 290.
[patch]
Index: src/core/com/jme3/font/LetterQuad.java
===================================================================
— src/core/com/jme3/font/LetterQuad.java (revision 6814)
+++ src/core/com/jme3/font/LetterQuad.java (revision )
@@ -299,13 +299,10 @@
// Adjust for kerning
BitmapCharacter lastChar = previous.getBitmapChar();
if (lastChar != null && block.isKerning()) {
-
int amount = lastChar.getKerning(c);<br />
-
if (amount != -1) {<br />
-
kernAmount = amount * sizeScale;<br />
-
kernAmount = lastChar.getKerning(c) * sizeScale;<br />
-
x0 += kernAmount * incrScale;<br />
-
}<br />
-
}<br />
-
x0 += kernAmount * incrScale;<br />
-
}<br />
-
}<br />
-
}<br />
if (isEndOfLine()) {
xAdvance = bound.x-x0;
}
Index: src/core/com/jme3/font/BitmapFont.java
===================================================================
— src/core/com/jme3/font/BitmapFont.java (revision 6768)
+++ src/core/com/jme3/font/BitmapFont.java (revision )
@@ -109,11 +109,8 @@
if (c == null)
return 0f;
-
int kerning = c.getKerning(nextChar);<br />
float advance = size * c.getXAdvance();
-
if (kerning != -1){<br />
-
advance += kerning * size;<br />
-
}<br />
-
advance += c.getKerning(nextChar) * size;<br />
return advance;
}
@@ -165,11 +162,8 @@
}
}
if (!firstCharOfLine){
-
int amount = findKerningAmount(lastChar, theChar);<br />
-
if (amount != -1){<br />
-
lineWidth += amount * sizeScale;<br />
-
lineWidth += findKerningAmount(lastChar, theChar) * sizeScale;<br />
-
}<br />
-
}<br />
-
}<br />
float xAdvance = c.getXAdvance() * sizeScale;
lineWidth += xAdvance;
}
Index: src/core/com/jme3/font/BitmapCharacter.java
===================================================================
— src/core/com/jme3/font/BitmapCharacter.java (revision 6768)
+++ src/core/com/jme3/font/BitmapCharacter.java (revision )
@@ -152,7 +152,7 @@
public int getKerning(int second){
Integer i = kerning.get(second);
if (i == null)
-
return -1;<br />
-
return 0;<br />
else
return i.intValue();
}
[/patch]
-davidc