Merge pull request #107338 from TelePete/label-ratio-fix

Fix visible ratio when displaying all characters in Label
This commit is contained in:
Rémi Verschelde 2025-06-10 12:30:49 +02:00
commit 6181a0c756
No known key found for this signature in database
GPG key ID: C3336907360768E1

View file

@ -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;