these code can be used in the SetTextSize(TextSizeValue(textsize0, cc, gPad)), where cc is a pointer of TCanvas;
double pad_width_for_textSizeValue0;
double pad_height_for_textSizeValue0;
double pad_width_for_textSizeValue;
double pad_height_for_textSizeValue;
double rel_charheight_for_textSizeValue0;
double rel_charheight_for_textSizeValue;
double ans_for_textSizeValue;
double TextSizeValue(double textsize0, TPad * pad0, TPad * pad)
{
pad_width_for_textSizeValue0 = pad0->XtoPixel(pad0->GetX2());
pad_height_for_textSizeValue0 = pad0->YtoPixel(pad0->GetY1());
if(pad_width_for_textSizeValue0 < pad_height_for_textSizeValue0)
rel_charheight_for_textSizeValue0 = pad_width_for_textSizeValue0;
else
rel_charheight_for_textSizeValue0 = pad_height_for_textSizeValue0;
pad_width_for_textSizeValue = pad->XtoPixel(pad->GetX2());
pad_height_for_textSizeValue = pad->YtoPixel(pad->GetY1());
if(pad_width_for_textSizeValue < pad_height_for_textSizeValue)
rel_charheight_for_textSizeValue = pad_width_for_textSizeValue;
else
rel_charheight_for_textSizeValue = pad_height_for_textSizeValue;
ans_for_textSizeValue = (rel_charheight_for_textSizeValue0 * textsize0)
/ rel_charheight_for_textSizeValue;
return ans_for_textSizeValue;
}