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];
|
ref TextBlock textBlock = ref textBlocks[i];
|
||||||
var textBlockSize = textBlock.Bounds.BottomRight - lineOrigin;
|
var textBlockSize = textBlock.Bounds.BottomRight - lineOrigin;
|
||||||
var ascender = textBlock.Ascender;
|
var ascender = textBlock.GetAscender();
|
||||||
//if (ascender <= 0)
|
|
||||||
{
|
|
||||||
var textBlockFont = textBlock.Style.Font.GetFont();
|
|
||||||
if (textBlockFont)
|
|
||||||
ascender = textBlockFont.Ascender;
|
|
||||||
}
|
|
||||||
lineAscender = Mathf.Max(lineAscender, ascender);
|
lineAscender = Mathf.Max(lineAscender, ascender);
|
||||||
lineSize = Float2.Max(lineSize, textBlockSize);
|
lineSize = Float2.Max(lineSize, textBlockSize);
|
||||||
}
|
}
|
||||||
@@ -256,13 +250,7 @@ namespace FlaxEngine.GUI
|
|||||||
case TextBlockStyle.Alignments.Baseline:
|
case TextBlockStyle.Alignments.Baseline:
|
||||||
{
|
{
|
||||||
// Match the baseline of the line (use ascender)
|
// Match the baseline of the line (use ascender)
|
||||||
var ascender = textBlock.Ascender;
|
var ascender = textBlock.GetAscender();
|
||||||
if (ascender <= 0)
|
|
||||||
{
|
|
||||||
var textBlockFont = textBlock.Style.Font.GetFont();
|
|
||||||
if (textBlockFont)
|
|
||||||
ascender = textBlockFont.Ascender;
|
|
||||||
}
|
|
||||||
vOffset = lineAscender - ascender;
|
vOffset = lineAscender - ascender;
|
||||||
textBlock.Bounds.Location.Y += vOffset;
|
textBlock.Bounds.Location.Y += vOffset;
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -31,5 +31,18 @@ namespace FlaxEngine.GUI
|
|||||||
/// The custom tag.
|
/// The custom tag.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public object Tag;
|
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