Tag: c# graphics gui .Net gdi+
c# drawing outlined text.
by brian on Mar.20, 2008, under .NET, GUI, c#, c# coding GUI, graphics
Here is a little nice bit of code to get text to jump out at you no matter what the background. Outlined text is especially useful when putting text on an image and don’t have control of the background contrast. Basically it draws a black boarder with a while fill.
// prepare to draw text StringFormat sf = new StringFormat(); sf.Alignment = StringAlignment.Center; sf.LineAlignment = StringAlignment.Center;// draw the text to a path System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath(); path.AddString(text, Font.FontFamily, 0, 14.0f, fillRect, sf); // fill in the outline g.FillPath(Brushes.White, path); // draw the outline g.DrawPath(new Pen(Color.Black,2.0f) , path);
