Fix Label auto-height and auto-width when text overflows the lines and it's wrapped

#358
This commit is contained in:
Wojtek Figat
2021-03-20 13:06:35 +01:00
parent 59b975499f
commit 7dd67b5ae3

View File

@@ -239,7 +239,13 @@ namespace FlaxEngine.GUI
if (font)
{
// Calculate text size
_textSize = font.MeasureText(_text);
var layout = TextLayoutOptions.Default;
layout.TextWrapping = Wrapping;
if (_autoHeight && !_autoWidth)
layout.Bounds.Size.X = Width - Margin.Width;
else if (_autoWidth && !_autoHeight)
layout.Bounds.Size.Y = Height - Margin.Height;
_textSize = font.MeasureText(_text, ref layout);
// Check if size is controlled via text
if (_autoWidth || _autoHeight)