# How to Implement Mixed Font Weights in GUI?

**URL:** <https://forum.babylonjs.com/t/how-to-implement-mixed-font-weights-in-gui/46582>\
**Category:** Questions\
**Tags:** gui\
**Created:** [December 19, 2023, 8:56pm UTC](https://forum.babylonjs.com/t/how-to-implement-mixed-font-weights-in-gui/46582 "2023-12-19T20:56:06Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![ertugrulcetin](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/ertugrulcetin/32/33011_2.png) [@ertugrulcetin](https://forum.babylonjs.com/u/ertugrulcetin)\
**Post date:** [December 19, 2023, 8:56pm UTC](https://forum.babylonjs.com/t/how-to-implement-mixed-font-weights-in-gui/46582/1 "2023-12-19T20:56:06Z")

</div>

I’m looking to recreate an HTML-like text layout within BabylonJS. I need to mix regular and bold text within the same line, similar to HTML’s `<span>Hello, <b>world</b></span>`.

The `TextBlock` component doesn’t seem to support this kind of layout since individual blocks don’t acknowledge each other’s presence and overlap. Is there a way to achieve automatic text layouting that allows for mixed font weights?

 ![Screenshot 2023-11-27 at 03.28.55](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/0/c/0cb5c73fd4003e43dab818ebe3837c3b5caef6f4.jpeg)

---

<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:** [December 20, 2023, 12:53pm UTC](https://forum.babylonjs.com/t/how-to-implement-mixed-font-weights-in-gui/46582/2 "2023-12-20T12:53:46Z")

</div>

Hello! There was a community pushed feature PR to allow structured text once, but it was not finished: [StructuredTextBlock (GUI 2D) by cronvel · Pull Request #11383 · BabylonJS/Babylon.js (github.com)](https://github.com/BabylonJS/Babylon.js/pull/11383). You can somewhat simulate this by using a stack panel with text with two different font styles: [Babylon.js Playground (babylonjs.com)](https://playground.babylonjs.com/#4ZB08K#1)

---

<div class="post-metadata">

**Author:** ![ertugrulcetin](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/ertugrulcetin/32/33011_2.png) [@ertugrulcetin](https://forum.babylonjs.com/u/ertugrulcetin)\
**Post date:** [December 20, 2023, 2:08pm UTC](https://forum.babylonjs.com/t/how-to-implement-mixed-font-weights-in-gui/46582/3 "2023-12-20T14:08:49Z")

</div>

Thanks! @carolhmj , do we have this equivalent in BabylonJS?

Demo: [three.js examples](https://threejs.org/examples/#webgl_geometry_text_shapes)  
Source: [three.js/examples/webgl\_geometry\_text\_shapes.html at master · mrdoob/three.js · GitHub](https://github.com/mrdoob/three.js/blob/master/examples/webgl_geometry_text_shapes.html)

---

<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:** [December 20, 2023, 2:21pm UTC](https://forum.babylonjs.com/t/how-to-implement-mixed-font-weights-in-gui/46582/4 "2023-12-20T14:21:13Z")

</div>

If you mean the outline and outline color, yes, there is:

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

As for the rest (mixing font styles and faces) within a single textBlock… NOPE,… sadly.  
@carolhmj @PatrickRyan I’d like to take this opportunity in case you plan to v2 the TB control, to state again my +1 👍 for this feature. In its simple version. In my opinion, the community project has gone beyond scope (and as said, never finished).

---

<div class="post-metadata">

**Author:** ![ertugrulcetin](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/ertugrulcetin/32/33011_2.png) [@ertugrulcetin](https://forum.babylonjs.com/u/ertugrulcetin)\
**Post date:** [December 20, 2023, 2:22pm UTC](https://forum.babylonjs.com/t/how-to-implement-mixed-font-weights-in-gui/46582/5 "2023-12-20T14:22:34Z")

</div>

Thank you for sharing this, but in the THREE.js demo the text built with shape geometry which is a 3d object I assume

---

<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:** [December 20, 2023, 2:28pm UTC](https://forum.babylonjs.com/t/how-to-implement-mixed-font-weights-in-gui/46582/6 "2023-12-20T14:28:18Z")

</div>

Sry, I didn’t look at the source (only the picture), lazy me 😉  
However, this example doesn’t look extruded to me. It can be easily reproduced with a GUI for mesh (plane) and in fact further modified towards the view from the camera using billboard mode.

---

<div class="post-metadata">

**Author:** ![ertugrulcetin](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/ertugrulcetin/32/33011_2.png) [@ertugrulcetin](https://forum.babylonjs.com/u/ertugrulcetin)\
**Post date:** [December 20, 2023, 2:31pm UTC](https://forum.babylonjs.com/t/how-to-implement-mixed-font-weights-in-gui/46582/7 "2023-12-20T14:31:52Z")

</div>

With 2D GUI I’m having some resolution problem, this example solves this problem in a way. If you have existing PG that does the same effect I’d like to checkout!

---

<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:** [December 20, 2023, 2:46pm UTC](https://forum.babylonjs.com/t/how-to-implement-mixed-font-weights-in-gui/46582/8 "2023-12-20T14:46:59Z")

</div>

Well, no, I don’t have one at hand. But any based on one of [the doc PG](https://doc.babylonjs.com/features/featuresDeepDive/gui/gui#texture-mode) could be created in minutes I suppose. What sort of resolution problem do you have? Do you mean the text is blurry, not crisp or is it something else?

---

<div class="post-metadata">

**Author:** ![ertugrulcetin](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/ertugrulcetin/32/33011_2.png) [@ertugrulcetin](https://forum.babylonjs.com/u/ertugrulcetin)\
**Post date:** [December 20, 2023, 3:07pm UTC](https://forum.babylonjs.com/t/how-to-implement-mixed-font-weights-in-gui/46582/9 "2023-12-20T15:07:35Z")

</div>

It is not that blurry, but not as sharp as in the demo I sent. The difference is like JPG vs SVG; some have limitations, while the other is vector-based.

---

<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:** [December 20, 2023, 3:12pm UTC](https://forum.babylonjs.com/t/how-to-implement-mixed-font-weights-in-gui/46582/10 "2023-12-20T15:12:40Z")

</div>

Are you in full-screen mode or texture mode. Did you try the solution for [crisp texts](https://playground.babylonjs.com/#2ARI2W#10) in FS mode. Else, in texture mode, use a higher resolution? And then, I suppose it will never reach the quality of SVG.

---

<div class="post-metadata">

**Author:** ![ertugrulcetin](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/ertugrulcetin/32/33011_2.png) [@ertugrulcetin](https://forum.babylonjs.com/u/ertugrulcetin)\
**Post date:** [December 20, 2023, 3:52pm UTC](https://forum.babylonjs.com/t/how-to-implement-mixed-font-weights-in-gui/46582/11 "2023-12-20T15:52:21Z")

</div>

I was in full-screen mode all the time, never used texture-mode, what is the diff?

Also when I zoom in browser you can see the quality diff:

 ![Screenshot 2023-12-20 at 18.53.41](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/b/3/b30f626855ec4bf1911056badc2f4536a47eb1a7.png)

---

<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:** [December 20, 2023, 5:04pm UTC](https://forum.babylonjs.com/t/how-to-implement-mixed-font-weights-in-gui/46582/12 "2023-12-20T17:04:00Z")

</div>

There is also MeshBuilder.CreateText that creates 3D text: [MeshBuilder.CreateText](https://forum.babylonjs.com/t/meshbuilder-createtext/40958) (and you could create it with a small depth so it looks 2D)
