From a7717d9ea2d19cdd459bff0088d6312411b8cfbd Mon Sep 17 00:00:00 2001 From: "PSp..om" Date: Mon, 24 Sep 2012 05:54:08 +0000 Subject: [PATCH] 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 --- engine/src/core/com/jme3/font/BitmapText.java | 56 +++++++++++++------ 1 file changed, 38 insertions(+), 18 deletions(-) diff --git a/engine/src/core/com/jme3/font/BitmapText.java b/engine/src/core/com/jme3/font/BitmapText.java index 231fcdb43..a1f9b77ee 100644 --- a/engine/src/core/com/jme3/font/BitmapText.java +++ b/engine/src/core/com/jme3/font/BitmapText.java @@ -112,29 +112,49 @@ public class BitmapText extends Node { */ public void setText(String 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()); + if (text == block.getText() || block.getText().equals(text)) { + return; + } + + /* + 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]); } - - // Update the text content - block.setText(text); - letters.setText(text); - // Flat for refresh - needRefresh = true; + 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; } /**