# Gui.get\_font additional usage (CLOSED)

**URL:** <https://forum.defold.com/t/gui-get-font-additional-usage-closed/8127>\
**Category:** Feature requests (USE GITHUB)\
**Created:** [May 7, 2017, 12:31am UTC](https://forum.defold.com/t/gui-get-font-additional-usage-closed/8127 "2017-05-07T00:31:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gmanicus](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/gmanicus/32/10312_2.png) [@Gmanicus](https://forum.defold.com/u/Gmanicus)\
**Post date:** [May 7, 2017, 12:31am UTC](https://forum.defold.com/t/gui-get-font-additional-usage-closed/8127/1 "2017-05-07T00:31:39Z")

</div>

Greetings,

I ran into an issue with the gui.get\_font function when I was trying to get the font itself within the gui object. I quickly understood that the way in which I was trying to use the function was incorrect, due to the fact that it’s supposed be used in reference to text nodes and to return the font used. I would like to suggest an additional usage, ex:

```lua
font = gui.get_font("myFont") -- myFont being located in the Fonts section of the gui object, instead of in Nodes

```

Hope I’m not missing anything that should be obvious.

Edit: I worked around this by getting the font of one of my constant objects which has the font I wanted to use, but it would be logical to be able to call the font itself as well so that it couldn’t become nil.

---

<div class="post-metadata">

**Author:** ![sicher](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/sicher/32/8_2.png) [@sicher](https://forum.defold.com/u/sicher)\
**Post date:** [May 7, 2017, 7:33am UTC](https://forum.defold.com/t/gui-get-font-additional-usage-closed/8127/2 "2017-05-07T07:33:13Z")

</div>

`gui.get_font()`returns the id of the font set on a text node:

```lua
local text_node = gui.get_node("my_text_node")
local font_id = gui.get_font(text_node)
	
print(font_id) --> DEBUG:SCRIPT: hash: [system_font]

```

If you want to set the font of a node, you don’t have to get the id first, just provide the id of the font that you set in the editor as a hash or a string:

```lua
local some_node = gui.get_node("text")
gui.set_font(some_node, hash("source_sans"))

```

 ![](https://forum-defold.b-cdn.net/uploads/default/original/2X/3/33aff66cde3aa873b1dfed8a00035acf47175010.png)

---

<div class="post-metadata">

**Author:** ![Gmanicus](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/gmanicus/32/10312_2.png) [@Gmanicus](https://forum.defold.com/u/Gmanicus)\
**Post date:** [May 7, 2017, 10:54pm UTC](https://forum.defold.com/t/gui-get-font-additional-usage-closed/8127/3 "2017-05-07T22:54:41Z")

</div>

Ah, I see! Thank you.
