# vtkLegendBoxActor is not supportting to set text font size

Hi,

I am using vtkLegendBoxActor to show legends in a plot. However, I am unable to control the font size of text in the legend.
I have tried the following:

``````legendActor=vtkLegendBoxActor()
textProp=vtkTextProperty()
textProp.SetFontSize(3)
textProp.SetVerticalJustificationToCentered()
legendActor.SetEntryTextProperty(textProp)
``````

However, this seems not set the font size of the text. It still appears the default size of 12. I have checked the font size after setting the property as:

``````legendActor.GetEntryTextProperty().GetFontSize()
``````

Thank you.

Hello,

Creating and setting composition objects is generally not advised in VTK. I’d simply do

``````legendActor.GetEntryTextProperty().SetFontSize(3)
``````

take care,

Paulo

Hi Paulo,
I tried it, but not working. I checked the source code and found that the font size is by default set to 12. And when user resizes the window, the font size is further adjusted to fit in the ‘Legend Box’.

Thank you,
Jishnu

Hi,

Please, try `legendActor.LockBorderOff()` and then set font size.

best,

PC

1 Like

Hi Paulo Carvalho,
Thank you for the answer. This is working.

1 Like