i’m using delphi,i have a text and i want to fit it into a cricle;by means i want to reduce the font of the text to keep it within the circle, i know the code of how keeping it into a rectangle ,but i;m a little confused with math function that allow me to keep it within circle
here’s the code of the rectangle i got from surfing the internet
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)) // Allow a little room on each side
{
// Calculate the position
m_labelOrigin.x = rectX + (width/2.0) - (te.cx/2);
m_labelOrigin.y = rectY + (height/2.0) - te.cy/2);
m_fontSize = fontSize;
bFontFits = true;
break;
}
fontSize -= 1.0;
}
I would adapt the code for a rectangle like this:
and change it a little bit to get it work for circles like this:
The result font size is in the canvas.