# Changing Font Size via Scripting

**URL:** <https://forum.inductiveautomation.com/t/changing-font-size-via-scripting/30882>\
**Category:** General Discussion\
**Created:** [December 21, 2019, 11:31am UTC](https://forum.inductiveautomation.com/t/changing-font-size-via-scripting/30882 "2019-12-21T11:31:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![qasimahtesham](https://avatars.discourse-cdn.com/v4/letter/q/a5b964/32.png) [@qasimahtesham](https://forum.inductiveautomation.com/u/qasimahtesham)\
**Post date:** [December 21, 2019, 11:31am UTC](https://forum.inductiveautomation.com/t/changing-font-size-via-scripting/30882/1 "2019-12-21T11:31:05Z")

</div>

Hi all,

I want to change the font size of text in a template(there will be a button in the template), essentially by binding it to a custom property (Boolean type). Where can I script it? and how?

So in short, its changing the font size of text in a button, via scripting, based on value of the custom property.

Thanks

---

<div class="post-metadata">

**Author:** ![lkruper](https://avatars.discourse-cdn.com/v4/letter/l/a88e4f/32.png) [@lkruper](https://forum.inductiveautomation.com/u/lkruper)\
**Post date:** [February 4, 2020, 7:21pm UTC](https://forum.inductiveautomation.com/t/changing-font-size-via-scripting/30882/2 "2020-02-04T19:21:00Z")

</div>

I am also trying to do this. I can change the text and name of a component with this code but when I try to change the font it errors with cannot convert to Java.Awt.Font.

event.source.parent.getComponent(compItem).font = “Elephant, Plain, 14”

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [February 4, 2020, 7:26pm UTC](https://forum.inductiveautomation.com/t/changing-font-size-via-scripting/30882/3 "2020-02-04T19:26:41Z")

</div>

If you want to _change_ the font size, then use `deriveFont` so you don’t need to construct a new instance yourself:

```auto
component = event.source.parent.getComponent(compItem)
component.font = component.font.deriveFont(14.0)

```

If you want to create a totally new font, then I would suggest importing and using [`java.awt.Font`](https://docs.oracle.com/javase/7/docs/api/java/awt/Font.html#decode(java.lang.String)) directly:

```auto
from java.awt import Font
component.font = Font.decode("Elephant PLAIN 14") # or Elephant-PLAIN-14

```
