# Not able to set font type for TLegend using GUI?

**URL:** <https://root-forum.cern.ch/t/not-able-to-set-font-type-for-tlegend-using-gui/59268>\
**Category:** Newbie\
**Created:** [May 8, 2024, 11:47am UTC](https://root-forum.cern.ch/t/not-able-to-set-font-type-for-tlegend-using-gui/59268 "2024-05-08T11:47:06Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![utkarsh-2000](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/u/e47774/32.png) [@utkarsh-2000](https://root-forum.cern.ch/u/utkarsh-2000)\
**Post date:** [May 8, 2024, 11:47am UTC](https://root-forum.cern.ch/t/not-able-to-set-font-type-for-tlegend-using-gui/59268/1 "2024-05-08T11:47:06Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Danilo](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/danilo/32/34528_2.png) [@Danilo](https://root-forum.cern.ch/u/Danilo)\
**Post date:** [May 8, 2024, 12:20pm UTC](https://root-forum.cern.ch/t/not-able-to-set-font-type-for-tlegend-using-gui/59268/2 "2024-05-08T12:20:25Z")

</div>

Hi,

Could you please post a reproducer?

D

---

<div class="post-metadata">

**Author:** ![utkarsh-2000](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/u/e47774/32.png) [@utkarsh-2000](https://root-forum.cern.ch/u/utkarsh-2000)\
**Post date:** [May 9, 2024, 8:43am UTC](https://root-forum.cern.ch/t/not-able-to-set-font-type-for-tlegend-using-gui/59268/3 "2024-05-09T08:43:02Z")

</div>

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](https://root-forum.cern.ch/uploads/short-url/TZqJ14VIHaoj55o8U7ugjF9hh9.root) (8.5 KB)

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

Thank You  
PS: root 6.24.04

---

<div class="post-metadata">

**Author:** ![Danilo](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/danilo/32/34528_2.png) [@Danilo](https://root-forum.cern.ch/u/Danilo)\
**Post date:** [May 9, 2024, 12:05pm UTC](https://root-forum.cern.ch/t/not-able-to-set-font-type-for-tlegend-using-gui/59268/4 "2024-05-09T12:05:35Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ferhue](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/ferhue/32/29462_2.png) [@ferhue](https://root-forum.cern.ch/u/ferhue)\
**Post date:** [May 10, 2024, 6:28am UTC](https://root-forum.cern.ch/t/not-able-to-set-font-type-for-tlegend-using-gui/59268/5 "2024-05-10T06:28:28Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![ferhue](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/ferhue/32/29462_2.png) [@ferhue](https://root-forum.cern.ch/u/ferhue)\
**Post date:** [May 10, 2024, 6:34am UTC](https://root-forum.cern.ch/t/not-able-to-set-font-type-for-tlegend-using-gui/59268/6 "2024-05-10T06:34:34Z")

</div>

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.]

---

<div class="post-metadata">

**Author:** ![utkarsh-2000](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/u/e47774/32.png) [@utkarsh-2000](https://root-forum.cern.ch/u/utkarsh-2000)\
**Post date:** [May 10, 2024, 6:43am UTC](https://root-forum.cern.ch/t/not-able-to-set-font-type-for-tlegend-using-gui/59268/7 "2024-05-10T06:43:11Z")

</div>

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

> [@ferhue](#):
>
> SetTextFont field only controls the font of the legend “header”

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

---

<div class="post-metadata">

**Author:** ![ferhue](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/ferhue/32/29462_2.png) [@ferhue](https://root-forum.cern.ch/u/ferhue)\
**Post date:** [May 10, 2024, 7:56am UTC](https://root-forum.cern.ch/t/not-able-to-set-font-type-for-tlegend-using-gui/59268/8 "2024-05-10T07:56:00Z")

</div>

> [@utkarsh-2000](#):
>
> 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:

> **[Issues · root-project/root](https://github.com/root-project/root/issues/)**
>
> The official repository for ROOT: analyzing, storing and visualizing big data, scientifically - Issues · root-project/root

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [May 13, 2024, 12:38pm UTC](https://root-forum.cern.ch/t/not-able-to-set-font-type-for-tlegend-using-gui/59268/9 "2024-05-13T12:38:35Z")

</div>

> [@utkarsh-2000](#):
>
> So is there any way of setting the font type of the “entries” using GUI?

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.

---

<div class="post-metadata">

**Author:** ![ferhue](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/ferhue/32/29462_2.png) [@ferhue](https://root-forum.cern.ch/u/ferhue)\
**Post date:** [May 13, 2024, 1:41pm UTC](https://root-forum.cern.ch/t/not-able-to-set-font-type-for-tlegend-using-gui/59268/10 "2024-05-13T13:41:01Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [May 13, 2024, 1:58pm UTC](https://root-forum.cern.ch/t/not-able-to-set-font-type-for-tlegend-using-gui/59268/11 "2024-05-13T13:58:45Z")

</div>

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.
