summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGen <z.rz2323721@gmail.com>2015-04-28 23:06:34 +0800
committerGen <z.rz2323721@gmail.com>2015-04-28 23:06:34 +0800
commit1a6012aff57498a476982f8dd918b5898da6e1f1 (patch)
tree2fbe57a1ab0127864887b8ce00498f5bf7dd82ee
parentc6dce44dd85c4ebae791756a76f6afbfbb0a5c28 (diff)
Update label.cpp
-rw-r--r--scene/gui/label.cpp42
1 files changed, 37 insertions, 5 deletions
diff --git a/scene/gui/label.cpp b/scene/gui/label.cpp
index 6afff81fde..951df155d5 100644
--- a/scene/gui/label.cpp
+++ b/scene/gui/label.cpp
@@ -170,7 +170,7 @@ void Label::_notification(int p_what) {
while(to && to->char_pos>=0) {
taken+=to->pixel_width;
- if (to!=from) {
+ if (to!=from && to->space_insert) {
spaces++;
}
to=to->next;
@@ -212,15 +212,15 @@ void Label::_notification(int p_what) {
ERR_PRINT("BUG");
return;
}
- if (from!=wc) {
+ if (from!=wc && from->space_insert) {
/* spacing */
x_ofs+=space_w;
if (can_fill && align==ALIGN_FILL && spaces) {
-
+
x_ofs+=int((size.width-(taken+space_w*spaces))/spaces);
}
-
-
+
+
}
@@ -411,6 +411,38 @@ void Label::regenerate_word_cache() {
}
+ }else if ((current < 65||current >90) && (current<97||current>122)) {
+ if (current_word_size>0) {
+
+ WordCache *wc = memnew( WordCache );
+ if (word_cache) {
+ last->next=wc;
+ } else {
+ word_cache=wc;
+ }
+ last=wc;
+
+ wc->pixel_width=current_word_size;
+ wc->char_pos=word_pos;
+ wc->word_len=i-word_pos;
+ current_word_size=0;
+ }
+ WordCache *wc = memnew( WordCache );
+ if (word_cache) {
+ last->next=wc;
+ } else {
+ word_cache=wc;
+ }
+ last=wc;
+
+ wc->pixel_width=font->get_char_size(current).width;
+ wc->char_pos=i;
+ wc->word_len=1;
+ wc->space_insert = false;
+ current_word_size=0;
+ word_pos = i+1;
+ line_width+=wc->pixel_width;
+ total_char_cache++;
} else {
if (current_word_size==0) {