我忽略了您的标志,而是(大致)向您展示如何对齐文本。很容易挑选出您的文本,将其拆分并绘制为两个单独的字符串!
string text2 = "Use TextFormatFlags and Rectangle objects to"
+ " align text in a rectangle.";
using (Font font2 = new Font("Arial", 12, FontStyle.Bold, GraphicsUnit.Point))
{
Rectangle rect2 = new Rectangle(150, 10, 130, 140);
// Create a TextFormatFlags with word wrapping, horizontal center and
// vertical center specified.
TextFormatFlags flags = TextFormatFlags.HorizontalLeft |
TextFormatFlags.VerticalCenter | TextFormatFlags.WordBreak;
// Draw the text and the surrounding rectangle.
TextRenderer.DrawText(e.Graphics, text2, font2, rect2, Color.Blue, flags);
e.Graphics.DrawRectangle(Pens.Black, rect2);
}