SetTextSize SetTextSizePixels - Why do my text sizes vary?

Dear Rooters!

I am making a canvas with nine pads, and in each pad I wish to write text with the same textsize!!! Instead I see that my textsizes increase through the loop of drawing the different pads. I am really confused about how the setTextSize function works. Does it use the size from the canvas or the pad? The pads are a little bit different in size, but the canvas is always the same so if this is used I don’t understand why my texts can have different sizes. I tried to work around the problem by using setTextSizePixels, but here I see that it doesn’t matter what size I write, the text-size is still extremely small, it seems that ROOT doesn’t “listen” to my commands. I read about the function that I need to have a font-precision larger than 2 for setTextSizePixles to work, but I cannot find how to set the precision of the font. Please help me! This was an unexpected and extremely frustrating problem!! I simply want to write text in different pads with equal textsize!

Regards,
Karin

Example:

root [0] TText t(.5,.5,"hello")
root [1] t.SetTextFont(23);
root [2] t.SetTextSize(22);
root [3] t.Draw()

See: ROOT: TAttText Class Reference

perfekt, thank you!

Hi @couet
Is there also a possibility to set this “globally” for the whole pad?
I create a new Canvas and want to add several TPaveText boxes all with the same font, size and fill style. However when I try gStyle->SetTextSize(16) all my text boxes seem to be empty.

        c[j] = new TCanvas(canv, canv, 1600, 900);
	gPad->SetLogy(1);
	gStyle->SetFillStyle(0);
	gStyle->SetTextFont(43);
        gStyle->SetTextSize(16);

This is my code and only the SetTextSize command seems to cause problems. When I set the text size for each TPaveText individually it works fine. I also tried the SetTextSizePixles command but that didn’t change anything.

Your help would be much appreciated :slight_smile:

Not really, each object in a pad have their own text attributes. moreover some object might have several kind of text. So a global setting as described here would be difficult to implement. May be create you own TStyle setting all the text attributes you need. Or change gStyle texts’ attributes in rootlogon.C

Okay, thank you for the info.