Reverting the changes made in r9389

http://code.google.com/p/jmonkeyengine/source/detail?spec=svn9389&r=9389
That caused the StringBlock to be recreated every
time the text was set to "".  Doing this blew away
90% of BitmapText's internal state causing subsequent
text to be the wrong size, misaligned, etc.
The original reason for the change needs to be revisited.
Big comment left in code with the original change commented
out.


git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@9765 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
PSp..om 12 years ago
parent e0df200dfd
commit a7717d9ea2
  1. 56
      engine/src/core/com/jme3/font/BitmapText.java

@ -112,29 +112,49 @@ public class BitmapText extends Node {
*/ */
public void setText(String text) { public void setText(String text) {
text = text == null ? "" : text; text = text == null ? "" : text;
if (!block.getText().equals(text)) {
// If the text is empty, reset
if (text.isEmpty()) {
detachAllChildren();
for (int page = 0; page < textPages.length; page++) {
textPages[page] = new BitmapTextPage(font, true, page);
attachChild(textPages[page]);
}
block = new StringBlock();
letters = new Letters(font, block, letters.getQuad().isRightToLeft());
}
// Update the text content if (text == block.getText() || block.getText().equals(text)) {
block.setText(text); return;
letters.setText(text); }
// Flat for refresh /*
needRefresh = true; The problem with the below block is that StringBlock carries
pretty much all of the text-related state of the BitmapText such
as size, text box, alignment, etc.
I'm not sure why this change was needed and the commit message was
not entirely helpful because it purports to fix a problem that I've
never encountered.
If block.setText("") doesn't do the right thing then that's where
the fix should go because StringBlock carries too much information to
be blown away every time. -pspeed
Change was made:
http://code.google.com/p/jmonkeyengine/source/detail?spec=svn9389&r=9389
Diff:
http://code.google.com/p/jmonkeyengine/source/diff?path=/trunk/engine/src/core/com/jme3/font/BitmapText.java&format=side&r=9389&old_path=/trunk/engine/src/core/com/jme3/font/BitmapText.java&old=8843
// If the text is empty, reset
if (text.isEmpty()) {
detachAllChildren();
for (int page = 0; page < textPages.length; page++) {
textPages[page] = new BitmapTextPage(font, true, page);
attachChild(textPages[page]);
}
block = new StringBlock();
letters = new Letters(font, block, letters.getQuad().isRightToLeft());
} }
*/
// Update the text content
block.setText(text);
letters.setText(text);
// Flag for refresh
needRefresh = true;
} }
/** /**

Loading…
Cancel
Save