# font.deriveFont problem

**URL:** <https://forum.inductiveautomation.com/t/font-derivefont-problem/52270>\
**Category:** Ignition\
**Created:** [October 23, 2021, 9:19am UTC](https://forum.inductiveautomation.com/t/font-derivefont-problem/52270 "2021-10-23T09:19:40Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aiasa21](https://avatars.discourse-cdn.com/v4/letter/a/aeb1de/32.png) [@Aiasa21](https://forum.inductiveautomation.com/u/Aiasa21)\
**Post date:** [October 23, 2021, 9:19am UTC](https://forum.inductiveautomation.com/t/font-derivefont-problem/52270/1 "2021-10-23T09:19:40Z")

</div>

Good morning!

I’m struggling to make work a simple font size change via scripting of a numeric label.

I create I template where I count the actual active alarms and according to the totalizer I change the font size.

I try using this code:

```auto
lblConteggioAllarmi = event.source.getComponent('lblConteggioAllarmi')
lblConteggioAllarmi.font = lblConteggioAllarmi.font.deriveFont(60.0) 

```

and this just to be sure to call the exact component:

```auto
event.source.getComponent('lblConteggioAllarmi').font = event.source.getComponent('lblConteggioAllarmi').font.deriveFont(60.0) 

```

but in both cases I have no size font change.

Where do I wrong?

Thank you for the help.

---

<div class="post-metadata">

**Author:** ![jespinmartin1](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jespinmartin1/32/57175_2.png) [@jespinmartin1](https://forum.inductiveautomation.com/u/jespinmartin1)\
**Post date:** [October 24, 2021, 5:11am UTC](https://forum.inductiveautomation.com/t/font-derivefont-problem/52270/2 "2021-10-24T05:11:19Z")

</div>

Both should work **BUT**

I think you mean

```auto
event.source.parent.getComponent('lblConteggioAllarmi').font = event.source.parent.getComponent('lblConteggioAllarmi').font.deriveFont(60.0)

```

Note you’re missing **parent** key words

---

<div class="post-metadata">

**Author:** ![Aiasa21](https://avatars.discourse-cdn.com/v4/letter/a/aeb1de/32.png) [@Aiasa21](https://forum.inductiveautomation.com/u/Aiasa21)\
**Post date:** [October 24, 2021, 8:37am UTC](https://forum.inductiveautomation.com/t/font-derivefont-problem/52270/3 "2021-10-24T08:37:23Z")

</div>

Good morning jespinmartin1,  
I’ve just tried to change the line in

```auto
event.source.parent.getComponent('lblConteggioAllarmi').font = event.source.parent.getComponent('lblConteggioAllarmi').font.deriveFont(60.0)

```

but I have this error:

**Traceback (most recent call last):**  
\*\* File “event:propertyChange”, line 71, in \*\*  
**TypeError: getComponent(): 1st arg can’t be coerced to int**

**Ignition v8.1.6 (b2021052512)**  
**Java: Azul Systems, Inc. 11.0.11**

where line 71 is the one I’ve just edit.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [October 24, 2021, 12:28pm UTC](https://forum.inductiveautomation.com/t/font-derivefont-problem/52270/4 "2021-10-24T12:28:27Z")

</div>

No, the parent keywords weren’t missing. (I presume that the propertyChange event is on the root container.)

I think you are running into the fact that the font on a label is evaluated only when text is to be drawn. As a passive property, .font doesn’t generate a change event itself. (It doesn’t show up in a property binding list as a possible source.) So the font **property** is likely changing, but the label isn’t being redrawn. You’ll probably have to assign to its .text property to make it redraw.

---

<div class="post-metadata">

**Author:** ![Aiasa21](https://avatars.discourse-cdn.com/v4/letter/a/aeb1de/32.png) [@Aiasa21](https://forum.inductiveautomation.com/u/Aiasa21)\
**Post date:** [October 24, 2021, 2:17pm UTC](https://forum.inductiveautomation.com/t/font-derivefont-problem/52270/5 "2021-10-24T14:17:04Z")

</div>

> [@pturmel](#):
>
> No, the parent keywords weren’t missing. (I presume that the propertyChange event is on the root container.)

Yes you are right, I manage the script on the root container and I have custom property for the different alarms (active, clear, ack and unacked). Then I make the count and I would like to change the font size according to the number of alarms ( \<10 between 10-99 and \>100 ).

Thanks for your help, I'll try to play on the text and I'll let you know the result.

---

<div class="post-metadata">

**Author:** ![jespinmartin1](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jespinmartin1/32/57175_2.png) [@jespinmartin1](https://forum.inductiveautomation.com/u/jespinmartin1)\
**Post date:** [October 24, 2021, 3:45pm UTC](https://forum.inductiveautomation.com/t/font-derivefont-problem/52270/6 "2021-10-24T15:45:45Z")

</div>

Then you are calling the script from itself. In that case just do  
`event.source.font=event.sount.font.deriveFont(60.0)`
