From a previous thread of yours I assume that this code is being executed inside a class derived from Button. In that case there's no need to do what you're doing. Just override the OnPaintBackground method instead of OnPaint.

That said, for future reference you have the Graphics.MeasureString and .MeasureCharacterRanges methods. I believe that MeasureCharacterRanges is more reliable in some situations.