Changing fonts in TLegend via gStyle

Hello fellow rooters,

I have a root style sheet set up which changes all my pad colors, borders, fonts, etc from the default root values. In particular, I prefer to use font 102 (courier bold) but there doesn’t seem to be any method in gStyle to set the legend font. Am I missing something simple?

Thanks!!

You are correct, currently the font is hardwired in the constructor. You must set
legend->SetTextFont(102);
to force a particular font.
I have modified TLegend in CVS head such that the default font can be taken from gStyle->GetTextFont().
Thanks for this remark.

Rene

I am still having issues setting the legend font from gStyle. I have tried using both gStyle->SetTextFont() and gStyle->SetLegendFont(), but neither option changes the default TLegend font.

Also, I have noticed that the TLegend::SetTextFont() method does not change the TLegend title font. Is there anyway to change the title font?

Thanks.

Can you post a small example showing what you are doing ?

Here is a minimal example.

gStyle->SetTextFont(132);
gStyle->SetLegendFont(132);
TH1F *hTemp;
TLegend *legend = new TLegend(0,0,1,1,"Title");
legend->AddEntry(hTemp,"Temp");
legend->Draw();

The resulting legend still has font code 62. Adding the following will change the font for the word “Temp”, but not the word “Title”.

Ok, you macro gives me the right font for Temp (no need to add legend->SetTextFont(132);).
But the Title font is not changed.
I will check

The default font set by gStyle->SetLegendFont() was ignored.
Now fixed in the SVN trunk.
Thanks for reporting.

Does gStyle->SetLegendFont() set both the title and entry fonts? Will gStyle->SetTextFont() no longer affect TLegend?

Thanks.

Yes It is implement that way now. It is weird that SetLegendFont was simply ignored.