Nuked TextFormatter.CalcRect and unit tests

This commit is contained in:
Tig
2024-07-20 11:45:55 -06:00
parent 71e14c8ad1
commit 4bdaef7ad6
2 changed files with 0 additions and 237 deletions

View File

@@ -1981,148 +1981,6 @@ public class TextFormatter
return lineIdx;
}
/// <summary>Calculates the rectangle required to hold text, assuming no word wrapping or alignment.</summary>
/// <remarks>
/// This API will return incorrect results if the text includes glyphs whose width is dependent on surrounding
/// glyphs (e.g. Arabic).
/// </remarks>
/// <param name="x">The x location of the rectangle</param>
/// <param name="y">The y location of the rectangle</param>
/// <param name="text">The text to measure</param>
/// <param name="direction">The text direction.</param>
/// <param name="tabWidth">The number of columns used for a tab.</param>
/// <returns></returns>
[Obsolete ("CalcRect is deprecated, FormatAndGetSize instead.")]
internal static Rectangle CalcRect (
int x,
int y,
string text,
TextDirection direction = TextDirection.LeftRight_TopBottom,
int tabWidth = 0
)
{
if (string.IsNullOrEmpty (text))
{
return new (new (x, y), System.Drawing.Size.Empty);
}
int w, h;
if (IsHorizontalDirection (direction))
{
var mw = 0;
var ml = 1;
var cols = 0;
foreach (Rune rune in text.EnumerateRunes ())
{
if (rune.Value == '\n')
{
ml++;
if (cols > mw)
{
mw = cols;
}
cols = 0;
}
else if (rune.Value != '\r')
{
cols++;
var rw = 0;
if (rune.Value == '\t')
{
rw += tabWidth - 1;
}
else
{
rw = rune.GetColumns ();
if (rw > 0)
{
rw--;
}
else if (rw == 0)
{
cols--;
}
}
cols += rw;
}
}
if (cols > mw)
{
mw = cols;
}
w = mw;
h = ml;
}
else
{
int vw = 1, cw = 1;
var vh = 0;
var rows = 0;
foreach (Rune rune in text.EnumerateRunes ())
{
if (rune.Value == '\n')
{
vw++;
if (rows > vh)
{
vh = rows;
}
rows = 0;
cw = 1;
}
else if (rune.Value != '\r')
{
rows++;
var rw = 0;
if (rune.Value == '\t')
{
rw += tabWidth - 1;
rows += rw;
}
else
{
rw = rune.GetColumns ();
if (rw == 0)
{
rows--;
}
else if (cw < rw)
{
cw = rw;
vw++;
}
}
}
}
if (rows > vh)
{
vh = rows;
}
w = vw;
h = vh;
}
return new (x, y, w, h);
}
/// <summary>Finds the HotKey and its location in text.</summary>
/// <param name="text">The text to look in.</param>
/// <param name="hotKeySpecifier">The HotKey specifier (e.g. '_') to look for.</param>