Fix Rich Text Box ascender usage in line breaks for correct images placement
#3292
This commit is contained in:
@@ -233,13 +233,7 @@ namespace FlaxEngine.GUI
|
||||
{
|
||||
ref TextBlock textBlock = ref textBlocks[i];
|
||||
var textBlockSize = textBlock.Bounds.BottomRight - lineOrigin;
|
||||
var ascender = textBlock.Ascender;
|
||||
//if (ascender <= 0)
|
||||
{
|
||||
var textBlockFont = textBlock.Style.Font.GetFont();
|
||||
if (textBlockFont)
|
||||
ascender = textBlockFont.Ascender;
|
||||
}
|
||||
var ascender = textBlock.GetAscender();
|
||||
lineAscender = Mathf.Max(lineAscender, ascender);
|
||||
lineSize = Float2.Max(lineSize, textBlockSize);
|
||||
}
|
||||
@@ -256,13 +250,7 @@ namespace FlaxEngine.GUI
|
||||
case TextBlockStyle.Alignments.Baseline:
|
||||
{
|
||||
// Match the baseline of the line (use ascender)
|
||||
var ascender = textBlock.Ascender;
|
||||
if (ascender <= 0)
|
||||
{
|
||||
var textBlockFont = textBlock.Style.Font.GetFont();
|
||||
if (textBlockFont)
|
||||
ascender = textBlockFont.Ascender;
|
||||
}
|
||||
var ascender = textBlock.GetAscender();
|
||||
vOffset = lineAscender - ascender;
|
||||
textBlock.Bounds.Location.Y += vOffset;
|
||||
break;
|
||||
|
||||
@@ -31,5 +31,18 @@ namespace FlaxEngine.GUI
|
||||
/// The custom tag.
|
||||
/// </summary>
|
||||
public object Tag;
|
||||
|
||||
internal float GetAscender()
|
||||
{
|
||||
float ascender = Ascender;
|
||||
if (Mathf.IsZero(ascender))
|
||||
{
|
||||
// Use ascender from the font
|
||||
var textBlockFont = Style.Font.GetFont();
|
||||
if (textBlockFont)
|
||||
ascender = textBlockFont.Ascender;
|
||||
}
|
||||
return ascender;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user