Question about TLegend fonts

Dear ROOT wizzards,

I’ve got a question about the TLegend. The constructor sets the header font to 62 to make it bold but SetHeader sets it to the default font. Is this a design choice or an oversight?

I’m using version 4.04/02 but I also see this in the current online source.

Thanks,
Jeroen

[quote]I’ve got a question about the TLegend. The constructor sets the header font to 62 to make it bold but SetHeader sets it to the default font. Is this a design choice or an oversight?
I’m using version 4.04/02 but I also see this in the current online source.
[/quote]
Where do you see this in the source?

Rene

Well, the ctor is here:
root.cern.ch/root/html/src/TLege … nd:TLegend
(look for the line ‘headerEntry->SetTextFont(62); // default font is 62 for the header’).

The SetHeader code is here:
root.cern.ch/root/html//src/TLeg … :SetHeader
(look for the line ‘first->SetTextFont(GetTextFont()); // default font is TLegend font for the header’)

[quote]The SetHeader code is here:
root.cern.ch/root/html//src/TLeg … :SetHeader
(look for the line ‘first->SetTextFont(GetTextFont()); // default font is TLegend font for the header’)[/quote]

This simply sets the font for the first line of the legend to be the same as
the legend current font. This looks perfectly logical.

Rene

Okay, I won’t argue about what’s the logical choice. The point I was making is that it’s inconsistent with what the constructor does.

Let’s look at the following two scenarios.

Scenario 1:
TLegend leg(0.7,0.7,0.9,0.9,“header”);

Scenario 2:
TLegend leg(0.7,0.7,0.9,0.9);
leg.SetHeader(“header”);

The first case will draw the legend header with font 62: bold. The second case will draw the legend header with the default entry font: 42, not bold.

I do not understand your point.
If I do what you say, I get:

root [0] TLegend leg(0.7,0.7,0.9,0.9,"header") root [1] leg.GetTextFont() (const Font_t)42 root [2] TLegend leg2(0.7,0.7,0.9,0.9) root [3] leg2.GetTextFont() (const Font_t)42 root [4] leg2.SetHeader("header") root [5] leg2.GetTextFont() (const Font_t)42

Rene

It will be obvious when you draw the legends. One will have bold text, the other will not.

Jeroen

Seems to me, the way it is done, is a convenient way to define a different font for the header, try:

{
   TFile f("hsimple.root");
   hpx->Draw("");
   hpx->SetFillColor(48);
                                                                                
   TLegend *leg=new TLegend(0.2,0.2,0.4,0.4);
   leg->AddEntry(hpx,"hpx","f");
   leg->SetTextFont(132);
   leg->SetHeader("Legend");
   leg->SetTextFont(42);
   leg->Draw();
}

62 in the ctor is just a default.