I have some in a class that puts text onto an image. I want the ability to put a solid background behind the text but I'm having trouble getting the width to be the correct width (it's always too long). I've tried change the unit and can't get it quiet right, anyone know what I'm missing (which is probably something simple)? Or, another way to phrase the question is, how do I get the length of the text in a format that FillRectangle matches up with? My snippet is in VB but I'll take either VB or C# suggestions, language is irrelevant for my purposes.
Dim Image As New Bitmap(_fileName)
Dim Gr As Graphics = Graphics.FromImage(Image)
Dim Brush As New System.Drawing.SolidBrush(_color)
Gr.FillRectangle(Brushes.Blue, _x, _y, (_font.SizeInPoints * _text.Length), _font.Height)
Gr.DrawString(Text, _font, Brush, _x, _y)