# How to change scalarbarwidget font properties

**URL:** https://discourse.vtk.org/t/how-to-change-scalarbarwidget-font-properties/10343
**Category:** Support
**Created:** [December 30, 2022, 4:09pm UTC](https://discourse.vtk.org/t/how-to-change-scalarbarwidget-font-properties/10343 "2022-12-30T16:09:33Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![BlueKnight7](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/b/838e76/32.png) [@BlueKnight7](https://discourse.vtk.org/u/BlueKnight7)
#### Post date: [December 30, 2022, 4:09pm UTC](https://discourse.vtk.org/t/how-to-change-scalarbarwidget-font-properties/10343/1 "2022-12-30T16:09:33Z")

</div>

I can’t find a way to change the scarlarbarwidget font properties such as size and color.

Can anyone help?

BK

---

<div class="post-metadata">

### Author: ![Paulo\_Carvalho](https://discourse.vtk.org/user_avatar/discourse.vtk.org/paulo_carvalho/32/370_2.png) [@Paulo\_Carvalho](https://discourse.vtk.org/u/Paulo_Carvalho)
#### Post date: [January 2, 2023, 6:03pm UTC](https://discourse.vtk.org/t/how-to-change-scalarbarwidget-font-properties/10343/2 "2023-01-02T18:03:45Z")

</div>

Hello,

Try calling `GetScalarBarActor()` on your `vtkScalarBarWidget` object. That method returns a pointer to a `vtkScalarBarActor` object. Call one of the `Get*TextProperty()` methods on it (one for title, another for the labels, etc.). Each of such methods returns a pointer to some `vtkTextProperty` object, which has lots of methods to change text style.

[https://vtk.org/doc/nightly/html/classvtkScalarBarActor.html](https://vtk.org/doc/nightly/html/classvtkScalarBarActor.html)  
[https://vtk.org/doc/nightly/html/classvtkTextProperty.html](https://vtk.org/doc/nightly/html/classvtkTextProperty.html)

regards,

Paulo

---

<div class="post-metadata">

### Author: ![BlueKnight7](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/b/838e76/32.png) [@BlueKnight7](https://discourse.vtk.org/u/BlueKnight7)
#### Post date: [January 4, 2023, 1:15am UTC](https://discourse.vtk.org/t/how-to-change-scalarbarwidget-font-properties/10343/3 "2023-01-04T01:15:42Z")

</div>

Hi Paulo,

Your advice basically got me to where I wanted to be. A couple of small points though.

1. The SetFontSize didn’t override the size that the scalarBarWidget had. I suspect that this is because the scalarBarWidget is re-sizeable and re-sizes accordingly. I haven’t taken the time to find out how to turn the re-size off. I probably don’t want that anyway.

2. I found it odd that vtkTextProperty has a GetShadowColor function, but no function to set the shadow color. Would be nice to do that. Maybe it is there somewhere; not obvious. Fortunately, I can turn the “white” shadow off with ShadowOff.

Thanks.

BK

---

<div class="post-metadata">

### Author: ![Paulo\_Carvalho](https://discourse.vtk.org/user_avatar/discourse.vtk.org/paulo_carvalho/32/370_2.png) [@Paulo\_Carvalho](https://discourse.vtk.org/u/Paulo_Carvalho)
#### Post date: [January 4, 2023, 1:34pm UTC](https://discourse.vtk.org/t/how-to-change-scalarbarwidget-font-properties/10343/4 "2023-01-04T13:34:41Z")

</div>

Hello,

> [@BlueKnight7](#):
>
> I found it odd that vtkTextProperty has a GetShadowColor function, but no function to set the shadow color. Would be nice to do that. Maybe it is there somewhere; not obvious. Fortunately, I can turn the “white” shadow off with ShadowOff.

New features can be proposed here: [Development - VTK](https://discourse.vtk.org/c/development/7).

---

<div class="post-metadata">

### Author: ![Paulo\_Carvalho](https://discourse.vtk.org/user_avatar/discourse.vtk.org/paulo_carvalho/32/370_2.png) [@Paulo\_Carvalho](https://discourse.vtk.org/u/Paulo_Carvalho)
#### Post date: [January 4, 2023, 1:38pm UTC](https://discourse.vtk.org/t/how-to-change-scalarbarwidget-font-properties/10343/5 "2023-01-04T13:38:54Z")

</div>

> [@BlueKnight7](#):
>
> The SetFontSize didn’t override the size that the scalarBarWidget had. I suspect that this is because the scalarBarWidget is re-sizeable and re-sizes accordingly. I haven’t taken the time to find out how to turn the re-size off. I probably don’t want that anyway.

Try calling `UnconstrainedFontSizeOff()` of the `vtkScalarBarActor` object in question before setting font size.

---

<div class="post-metadata">

### Author: ![BlueKnight7](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/b/838e76/32.png) [@BlueKnight7](https://discourse.vtk.org/u/BlueKnight7)
#### Post date: [January 4, 2023, 8:48pm UTC](https://discourse.vtk.org/t/how-to-change-scalarbarwidget-font-properties/10343/6 "2023-01-04T20:48:25Z")

</div>

`UnconstrainedFontSizeOff()` had no effect.

---

<div class="post-metadata">

### Author: ![BlueKnight7](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/b/838e76/32.png) [@BlueKnight7](https://discourse.vtk.org/u/BlueKnight7)
#### Post date: [January 4, 2023, 9:27pm UTC](https://discourse.vtk.org/t/how-to-change-scalarbarwidget-font-properties/10343/7 "2023-01-04T21:27:13Z")

</div>

`UnconstrainedFontSizeOn()` worked.
