# Changing Font Style in GUI breaks font size

**URL:** <https://forum.babylonjs.com/t/changing-font-style-in-gui-breaks-font-size/37007>\
**Category:** Bugs\
**Tags:** gui, gui-editor\
**Created:** [December 31, 2022, 2:52am UTC](https://forum.babylonjs.com/t/changing-font-style-in-gui-breaks-font-size/37007 "2022-12-31T02:52:11Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![jamessimo](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/jamessimo/32/26847_2.png) [@jamessimo](https://forum.babylonjs.com/u/jamessimo)\
**Post date:** [December 31, 2022, 2:52am UTC](https://forum.babylonjs.com/t/changing-font-style-in-gui-breaks-font-size/37007/1 "2022-12-31T02:52:11Z")

</div>

I am quite happy I found the trigger for this bug because its been something I found in production but at the time had no idea what caused it.

**The issue:**

 ![Screenshot 2022-12-31 at 10.30.41 AM](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/d/5/d5264340d9722f82aee20057334a190b4be1bd8f.png)  
Both of these text blocks are _ **the exact same in every-way.** _ Both of these have a font sizeof 78px, same height, width etc…  
What caused this was changing the font style to italic then back to regular.

> **[Babylon.js Gui Editor](https://gui.babylonjs.com/#ITIC05)**
>
> Babylon.js GUI editor - web based UI editor for Babylon.js

Here is a snippet that shows this in action.

**My research:**  
This is caused by changing the font style. Be it in the GUI or later via code  
it not impacted if you have resize-to-fit on or off  
This is not the GUI being funny, I have created a .json from scratch and it produces the same outcome.

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [January 2, 2023, 2:23pm UTC](https://forum.babylonjs.com/t/changing-font-style-in-gui-breaks-font-size/37007/2 "2023-01-02T14:23:34Z")

</div>

Assigned @carolhmj on January 2, 2023, 2:23pm UTC



---

<div class="post-metadata">

**Author:** ![carolhmj](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/carolhmj/32/25918_2.png) [@carolhmj](https://forum.babylonjs.com/u/carolhmj)\
**Post date:** [January 2, 2023, 3:26pm UTC](https://forum.babylonjs.com/t/changing-font-style-in-gui-breaks-font-size/37007/3 "2023-01-02T15:26:16Z")

</div>

Hello! Thanks for the report, a fix will be in this PR: [Fix font style options on gui editor. by carolhmj · Pull Request #13392 · BabylonJS/Babylon.js (github.com)](https://github.com/BabylonJS/Babylon.js/pull/13392)

---

<div class="post-metadata">

**Author:** ![mawa](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/mawa/32/12384_2.png) [@mawa](https://forum.babylonjs.com/u/mawa)\
**Post date:** [January 2, 2023, 3:59pm UTC](https://forum.babylonjs.com/t/changing-font-style-in-gui-breaks-font-size/37007/4 "2023-01-02T15:59:04Z")

</div>

I have to extend on this as I found other similar issues with the Editor.  
I only thought it would be best to keep it for after the first day following New Year as I don’t want to start the year complaining about issues 😀 😉

There are still a number of (sometimes very annoying issues) with the Editor; I will likely post tomorrow in my GUI Editor debug post. But since we are talking fonts and inheritance, you should have a closer look at what happens when a control is reparented. Seems like all font styling is overwritten by the new parent if the parent is left with default (Arial, 18px). I’m not sure whether if this happens when a single control is parented to a new container. I have to do some further tests. What happened to me (yesterday and this morning) is that I had an assembly of containers and controls (rectangle main container + grid + rectangle + textBlock) with font styling set only on the textBlock. Next thing that happened when I reparented my assembly to a new rectangle container, all of my text blocks went back to the default styling (unset in the new parent, Arial, 18px).  
Though, from what I understood, all children should keep with their styling if set. They inherit from the parent at first but if modified, they should keep with their own styling. Moving the control to a new parent should not be affecting the custom font styling of a control. Correct?

---

<div class="post-metadata">

**Author:** ![carolhmj](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/carolhmj/32/25918_2.png) [@carolhmj](https://forum.babylonjs.com/u/carolhmj)\
**Post date:** [January 2, 2023, 4:29pm UTC](https://forum.babylonjs.com/t/changing-font-style-in-gui-breaks-font-size/37007/5 "2023-01-02T16:29:37Z")

</div>

Yep, that definitely should work, I’ll take a look into this now 🤔

---

<div class="post-metadata">

**Author:** ![carolhmj](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/carolhmj/32/25918_2.png) [@carolhmj](https://forum.babylonjs.com/u/carolhmj)\
**Post date:** [January 2, 2023, 4:54pm UTC](https://forum.babylonjs.com/t/changing-font-style-in-gui-breaks-font-size/37007/6 "2023-01-02T16:54:13Z")

</div>

Do you have an example of this unstyling happening? I’m trying to reproduce here but I couldn’t get it to happen 🤔

---

<div class="post-metadata">

**Author:** ![mawa](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/mawa/32/12384_2.png) [@mawa](https://forum.babylonjs.com/u/mawa)\
**Post date:** [January 3, 2023, 4:46pm UTC](https://forum.babylonjs.com/t/changing-font-style-in-gui-breaks-font-size/37007/7 "2023-01-03T16:46:23Z")

</div>

> [@carolhmj](#):
>
> Do you have an example of this unstyling happening?

I need to set-up one. Also, I have been using a custom font from typekit, may be it only does it with custom fonts. Will check back on this shortly and let you know.

---

<div class="post-metadata">

**Author:** ![carolhmj](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/carolhmj/32/25918_2.png) [@carolhmj](https://forum.babylonjs.com/u/carolhmj)\
**Post date:** [January 3, 2023, 7:21pm UTC](https://forum.babylonjs.com/t/changing-font-style-in-gui-breaks-font-size/37007/8 "2023-01-03T19:21:04Z")

</div>

Ooooh, the custom font is likely, I’ll wait for your example 😮

---

<div class="post-metadata">

**Author:** ![jamessimo](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/jamessimo/32/26847_2.png) [@jamessimo](https://forum.babylonjs.com/u/jamessimo)\
**Post date:** [January 8, 2023, 6:32am UTC](https://forum.babylonjs.com/t/changing-font-style-in-gui-breaks-font-size/37007/9 "2023-01-08T06:32:54Z")

</div>

Thank you so much for the amazingly quick turnaround, I can confirm that this has solved the issue!

---

<div class="post-metadata">

**Author:** ![carolhmj](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/carolhmj/32/25918_2.png) [@carolhmj](https://forum.babylonjs.com/u/carolhmj)\
**Post date:** [January 17, 2023, 1:06pm UTC](https://forum.babylonjs.com/t/changing-font-style-in-gui-breaks-font-size/37007/10 "2023-01-17T13:06:42Z")

</div>

Unassigned @carolhmj on January 17, 2023, 1:06pm UTC


