I had a similar problem when I needed to adjust the font size to keep the name of my object within the borders of rectangles, not circles. I used a while loop and continued to check the extent size of the text in the string, reducing the font size to fit it.
Here is what I did: (this uses C ++ under Kylix, a Delphi derivative).
double fontSize = 20.0; bool bFontFits = false; while (bFontFits == false) { m_pCanvas->Font->Size = (int)fontSize; TSize te = m_pCanvas->TextExtent(m_name.c_str()); if (te.cx < (width*0.90))
Of course, this does not show error checking. If the rectangle (or your circle) is too small, you will have to exit the loop.
Steve source share