The simple attached PyRoot script and png file demonstrate the problem.
When the canvas is viewed interactively, or a png image is saved, the text in the two boxes is correctly aligned (right side of image). However, when a PDF is saved, the text is no longer correctly aligned (left side of image, from a screenshot of the PDF).
This problem occurs in multiple ROOT versions (6.06, 6.12, 6.22), in both Python and C++. In addition to PDF, it also occurs for the EPS format.
Is the conclusion that ROOT does not support consistent alignment of text? Or is there a deterministic way to make this work in publication-quality image formats? (The attached script shows clearly that the two TPaveText objects have the same y coordinates.)
The fonts used to produce the plot on screen and the Adobe native ones used in PDF are slightly different. The alignment is done the best possible way but it does not always matches perfectly. Concentrate of the pdf output if that’s the one you need at the end.
For the on-screen display or the PNG, two TPaveText objects with the same y coordinates are properly aligned.
For the PDF, two TPaveText objects with the same y coordinates are not aligned. Without a deterministic way to adjust the y coordinates (or possibly some other settings) to produce output that is guaranteed to be aligned, the only recourse seems to be an extremely tedious process of trial and error. That is not satisfactory.
Fascinatingly, the alignment actually works correctly and consistently in all formats if just TLatex is used. The problem appears to be isolated to TPaveText. Therefore, it seems the solution is just not to use TPaveText for this kind of application.
With TPaveText you add an extra parameter which can leads to some more misalignment which is the fact the text position is computed automatically to make the various lines of text fit inside the box. A slight difference in the fonts (as I explained before) might be increased. Surely using directly TLatex will minimise tis effect,