mirror of
https://github.com/godotengine/godot.git
synced 2025-02-23 23:15:07 +08:00
Let the cached TextLine
reset the width in get_string_size
Previously, the cached `TextLine` would set the width in `draw_string`, but not in `get_string_size`, which resulted in unexpected results returned by `get_string_size` in some cases.
This commit is contained in:
parent
307f560b39
commit
332c566a6c
@ -272,13 +272,15 @@ Size2 Font::get_string_size(const String &p_text, HorizontalAlignment p_alignmen
|
|||||||
buffer->set_direction(p_direction);
|
buffer->set_direction(p_direction);
|
||||||
buffer->set_orientation(p_orientation);
|
buffer->set_orientation(p_orientation);
|
||||||
buffer->add_string(p_text, Ref<Font>(this), p_font_size);
|
buffer->add_string(p_text, Ref<Font>(this), p_font_size);
|
||||||
if (p_alignment == HORIZONTAL_ALIGNMENT_FILL) {
|
|
||||||
buffer->set_horizontal_alignment(p_alignment);
|
|
||||||
buffer->set_width(p_width);
|
|
||||||
buffer->set_flags(p_jst_flags);
|
|
||||||
}
|
|
||||||
cache.insert(hash, buffer);
|
cache.insert(hash, buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
buffer->set_width(p_width);
|
||||||
|
buffer->set_horizontal_alignment(p_alignment);
|
||||||
|
if (p_alignment == HORIZONTAL_ALIGNMENT_FILL) {
|
||||||
|
buffer->set_flags(p_jst_flags);
|
||||||
|
}
|
||||||
|
|
||||||
return buffer->get_size();
|
return buffer->get_size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user