private void DrawText(RenderParameters parameters, Graphics graphics, Image image, LineParameters line, Rectangle bounds, StringFormat stringFormat) { var done = false; var fontSize = line.FontSize; var fontFamily = FindFont(parameters, line.Font); while (!done) { var font = new Font(fontFamily, fontSize, FontStyle.Regular); var size = graphics.MeasureString(line.Text, font, bounds.Width); if (size.Height > bounds.Size.Height && fontSize > 10) { fontSize -= 2; continue; } var stroke = new SolidBrush(line.Stroke); var fill = new SolidBrush(line.Fill); DrawText(graphics, line.Text, font, line.FontStyle, fontSize, stroke, line.StrokeWidth, fill, stringFormat, bounds); if (parameters.DebugMode) { DrawBoxes(graphics, image.Width, image.Height, bounds); } done = true; } }