how to calculate the textsize of TLatex in CernRoot

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/kakakaco/article/details/52823847

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;
}


ref: https://root.cern.ch/doc/master/classTAttText.html

阅读更多
想对作者说点什么?

博主推荐

换一批

没有更多推荐了,返回首页