ROOT can't paint text with same size in different pads

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.

Do you have a complete script showing this issue ?

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).

TextSize.C (512 Bytes)

One can then see that the last "L"s have sizes:
20.8517 and 20.7989 with my root version 6.09.

Thanks. I will check.

I just did the following exercise.

  1. modify you macro to draw the bottom Ls in red
  2. execute the macro
  3. set the opacity of the bottom pad to 0
  4. move up the bottom pad on top of the top pad to see if the Ls have the same size
  5. seems to me they have … I get the following image.

I will now check the output files

Hi, you can try this one.
Without any changes, just run it and see output.
It seems that even moving pad may have some effect.

TextSize2.C (1021 Bytes)

I see in png output that up "L"s with sizes 37 and 38 have the same size for upper pad.
Whereas for the bottom pad it’s not the case.

For PDF output it’s the same, I can see it when I zoom it to 1600%. Or just to open it in some vector graphics editior like Inkscape or Corel.

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 :slight_smile:


The pdf is exactly the same.

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.

The bottom pad looks like that:

I just did it on Mac using PaintBrush on output.png generated by TextSize2.C and I get:

The Red text overlaps the black one exactly… again I see the numbers are not exactly the same in SVG so I will look

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.

eps files can be also directly read by the text editor.

I know…

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.

As I said I am not ignoring it …

Thanks, let me know in case the reason would be found or possibly corrected in some next ROOT release.
I am always happy to make things work better.

####Side note:

I noticed it is a TLatex issue only. If I modify your macro using TText instead of TLatex I get exactly the same size in both pads.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.