// Render some text with the given font inside the given rectangle. Either center or left flush.
        // If the rectange doesn't intersect the clip rectangle, do nothing. Word wrap if needed.
        private void RenderWrappedText(IRenderer renderer, int fontIndex, StringAlignment alignment, string s, float left, float top, float right, float bottom, RectangleF clipRect)
        {
            if (s == null || s == "")
                return;

            RectangleF rect = new RectangleF(left, top, right - left, bottom - top);
            if (!rect.IntersectsWith(clipRect))
                return;

            object currentFont = fonts[fontIndex];
            float currentHeight = fontDescs[fontIndex].EmHeight;

            // Keep shrinking the font by 5% until it fits.
            bool fits;
            do {
                fits = renderer.WrappedTextFits(currentFont, s, rect, alignment);
                if (!fits) {
                    currentHeight *= 0.95F;
                    currentFont = renderer.CreateFont(fontDescs[fontIndex].Name, currentHeight, fontDescs[fontIndex].Bold, fontDescs[fontIndex].Italic, fontAlignments[fontIndex]);
                }
            } while (!fits);

            renderer.DrawWrappedText(currentFont, s, rect, alignment);
        }