Saving as PDF causes font to blow up

The following code run using python3 -i test.py causes the font in the displayed root window to be huge (first picture below):

import ROOT

canvas = ROOT.TCanvas()

latex = ROOT.TLatex()
latex.SetNDC()
latex.SetTextFont(61)
latex.DrawLatex(0.5,0.5,"MU")

canvas.SaveAs("test.pdf")

canvas.Modified()
canvas.Update()

The saved pdf file itself has the proper size font, as shown in the second image. The problem does not appear, if I for example use font 62 instead (but for example 60 also has the problem), save it as a .png file instead (or don’t save it at all), or if I set ROOT.gStyle.SetCanvasPreferGL(True) in the beginning. Also clicking in the ROOT window on the center where the small font would be makes the font become the proper small size again (but only clicking on the very center, not on the whole big font area). This looks like a bug or maybe my system has some problems with fonts?


ROOT Version: 6.19.01
Platform: Ubuntu 18.04
Compiler: gcc 7.4
Python: 3.6.8


Yes you should use for 62.
By the way to do not see the problem with:

{
   auto canvas = new TCanvas();
   auto latex =  new TLatex();
   latex->SetNDC();
   latex->SetTextFont(61);
   latex->DrawLatex(0.5,0.5,"MU");
   canvas->SaveAs("test.pdf");
}

even with 61 … but yes the right value is 62.

If I run the code you posted, I get the font blow-up problem, like in the first picture in the OP.

I guess it is then something due to my system. Anyway, it’s not that important, I can use 62 instead, just thought it might point to some problem.

62 is the right value …

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