Browse Source

Fix visible ratio when displaying all characters in Label

TelePete 1 month ago
parent
commit
a4ba3d5bed
1 changed files with 3 additions and 3 deletions
  1. 3 3
      scene/gui/label.cpp

+ 3 - 3
scene/gui/label.cpp

@@ -1269,10 +1269,10 @@ String Label::get_text() const {
 void Label::set_visible_characters(int p_amount) {
 	if (visible_chars != p_amount) {
 		visible_chars = p_amount;
-		if (get_total_character_count() > 0) {
-			visible_ratio = (float)p_amount / (float)get_total_character_count();
-		} else {
+		if (p_amount == -1 || get_total_character_count() == 0) {
 			visible_ratio = 1.0;
+		} else {
+			visible_ratio = (float)p_amount / (float)get_total_character_count();
 		}
 		if (visible_chars_behavior == TextServer::VC_CHARS_BEFORE_SHAPING) {
 			text_dirty = true;