我有一些代码:
string text = "Some text\t with tabs\t here!";
string spaces = "";
for (int i = 0; i < 4; i++)
{
spaces += " ";
}
text = text.Replace(@"\t", spaces);
我将所有制表符替换为四个空格,然后尝试绘制文本:
graphics.DrawString(text, font, new SolidBrush(Color.Black), offsetX, offsetY);
但是文本中单词之间只有一个空格,而其他空格已被删除。如何绘制包含所有空格的文本?