Not able to set font type for TLegend using GUI?

Hi all,

I added a legend to existing canvas using the ``BuildLegend()`

I am not able to set the font type to ‘times’ as doing that through the GUI seems to have no effect on the entry labels ?

Although, the font size and color seem to work fine.

Can someone please help in this?

Hi,

Could you please post a reproducer?

D

Hi @Danilo ,

Thank You for reply.

Please find a root file coating a canvas which has a histogram and a legend. I am not able to set the FontType in the SetTextAttributes for the TLegend.

legend_font_forum.root (8.5 KB)

Please let me know if you are unable to access the histogram.

Thank You
PS: root 6.24.04

Hi,

Thanks. 6.24 is a very old version: I would suggest to verify whether this behaviour is present in 6.30.06 before anything else.

Cheers,
D

I confirm on my side that this seems a bug and it’s still there in 6.33/01

@couet If I click on Inspect after changing the font, the fTextFont field is changed, but no Redraw/Update is called.

In contrast, if I change the text color, the object is correctly redrawn.

Ok, I figured out that the SetTextFont field only controls the font of the legend “header”, but not of the contained legend “entries”. [EDIT: Maybe not, it controls the font of the ‘future entries’, not of the previous ones’. So something is wrong with the TLegend::PaintPrimitives function.]

Thank You, @ferhue, for confirming and also sharing the observation.

So is there any way of setting the font type of the “entries” using GUI?

The only solution would be that you submit a bug report here:

No, you should change it from the code macro. The TLegend interactive editor does not act on individual entries as they got their attributes from the object they represent.

One question, why does the legend interactive editor then change the color of all individual entries?

Yes, I agree with you. I guess it is because fnt is taken from : TStyle::SetLegendFont and the value set by the editor is ignored.