ROOT does not paint text with the same size even when the size is set in pixels.
As a proof I in providing the plot with ratio which contains two pads.
The size of letters in up and down pads differs on average by 0.3%.
The testing letters “L” where plotted as:
TLatex *lat = new TLatex;
lat->SetTextFont(43);
lat->SetNDC();
for(int i = 0; i < 40; ++i) {
lat->SetTextSize(i);
lat->DrawLatexNDC(0.1+i/50., 0.08, "L");
}
Note that the letters which I tagged with red rectange where even plotted with the same size althouth their input ROOT size in pixel is different (for sizes 22,23 up and 21,22 down).
I am providing also the table of sizes of “L” obtained from pdf output.
The following script can be the simplest way how to reproduce this problem.
The SVG output is probably not the same as PNG or PDF, but the SVG file can be open in text editor and the issue is seen immediately.
In the previous comment the output was PNG for picture (here really the bad behavior was seen visually) and I tried also PDF from which the table was created (using Inkscape to read PDF).
Thanks, I will check.
Note that I am not saying there is no effect. What I claim is: it is very small.
I just cannot see it directly myself without looking at the numbers in the SVG file.
For instance for the biggest L we have in one case 20.8515 and in the other 20.7991
…
My eyes are not as good as yours to see a visual difference. Any way I will check that… doing it now…
Yes, sorry, the previous toy example TextSize.C was not so good.
The TextSize2.C has exactly the same pad sizes as in the first post.
Here one can sometimes see these different steps in sizes.
0.3% is really not visible by eye but the fact that pixel size 36 in upper pad is as large as pixel size 37 in down pad. It is more apparent that is 37/36 ~ 3% difference (see the table above).
I just did the same exercise as before with you new macro. This time I generate the png and pdf file from the canvas on screen. and I get the attached result … quite good match …
I am not saying there is no difference, one can see the numbers… I am just saying that’s it is not visually obvious …
By the way in which context to you need this “exact matching” ?
Yes, when I tried to move the pad, it dissapears.
One needs really the output of TextSize2.C and move the labels in graphic editor for png or pdf output.
This is the right part of upper pad, 37 and 38 have same size.
Actually SVG output doesn’t work properly in ROOT and is often diffrent than pdf or eps or png.
You can try to add the line to file TextSize2.C
can->SaveAs(“output.eps”);
eps files can be also directly read by the text editor.
For last four “L” in the upper pad you have sizes 77.266, 79.5385, 79.5385, 81.811
gsave 2268 964 0 788 C 1858.71 1656.48 t 0 r /Helvetica findfont 77.266 sf 0 0 m (L) show NC gr
gsave 2268 964 0 788 C 1904.15 1656.48 t 0 r /Helvetica findfont 79.5385 sf 0 0 m (L) show NC gr
gsave 2268 964 0 788 C 1949.6 1656.48 t 0 r /Helvetica findfont 79.5385 sf 0 0 m (L) show NC gr
gsave 2268 964 0 788 C 1995.05 1656.48 t 0 r /Helvetica findfont 81.811 sf 0 0 m (L) show NC gr
For the bottom pad 77.469, 77.469, 79.7475, 82.026
gsave 2268 788 0 0 C 1858.71 63.6233 t 0 r /Helvetica findfont 77.469 sf 0 0 m (L) show NC gr
gsave 2268 788 0 0 C 1904.15 63.6233 t 0 r /Helvetica findfont 77.469 sf 0 0 m (L) show NC gr
gsave 2268 788 0 0 C 1949.6 63.6233 t 0 r /Helvetica findfont 79.7475 sf 0 0 m (L) show NC gr
gsave 2268 788 0 0 C 1995.05 63.6233 t 0 r /Helvetica findfont 82.026 sf 0 0 m (L) show NC gr
These font sizes should be the same for top and bottom pad and should grow because here, for showed lines, the font was set to 36, 37, 38, 39 px.
So in particular if one set your font size to 37px one have font of size 79.5 in upper pad and of size 77.5 in lower pad.
79.5 is not equal to 77.5, that is my statement.
Yes, it’s maybe small effect (few percents) but I would be happier to have the same font sizes in my plots when I set them to be the same.