Skip to content

Commit 7e80213

Browse files
committed
Document setting up font outline, shadow and MSDF in Using fonts
Screenshots were previously committed but were unused, as I previously forgot to write these sections.
1 parent d8a2cf9 commit 7e80213

File tree

2 files changed

+71
-0
lines changed

2 files changed

+71
-0
lines changed

tutorials/ui/gui_using_fonts.rst

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,60 @@ property that accepts a Font resource.
156156
The texture filter mode can also be set on individual nodes that inherit from CanvasItem
157157
by setting :ref:`CanvasItem.texture_filter <class_CanvasItem_property_texture_filter>`.
158158

159+
Font outlines and shadows
160+
-------------------------
161+
162+
Font outlines and shadows can be used to improve readability when the background
163+
color isn't known in advance. For instance, this is the case for HUD elements
164+
that are drawn over a 2D/3D scene.
165+
166+
Font outlines are available in most nodes that derive from Control, in addition
167+
to :ref:`class_Label3D`.
168+
169+
To enable outline for a font on a given node, configure the theme overrides
170+
**Font Outline Color** and **Outline Size** in the inspector. The result should
171+
look like this:
172+
173+
.. figure:: img/using_fonts_outline_example.webp
174+
:align: center
175+
:alt: Font outline example
176+
177+
Font outline example
178+
179+
.. note::
180+
181+
If using a font with MSDF rendering, its **MSDF Pixel Range** import option
182+
be set to at least *twice* the value of the outline size for outline
183+
rendering to look correct. Otherwise, the outline may appear to be cut off
184+
earlier than intended.
185+
186+
Support for font shadows is more limited: they are only available in
187+
:ref:`class_Label` and :ref:`class_RichTextLabel`. Additionally, font shadows
188+
always have a hard edge (but you can reduce their opacity to make them look more
189+
subtle). To enable font shadows on a given node, configure the **Font Shadow
190+
Color**, **Shadow Offset X**, and **Shadow Offset Y** theme overrides in a Label
191+
or RichTextLabel node accordingly:
192+
193+
.. figure:: img/using_fonts_shadow.webp
194+
:align: center
195+
:alt: Configuring font shadow in a Label node
196+
197+
Configuring font shadow in a Label node
198+
199+
The result should look like this:
200+
201+
.. figure:: img/using_fonts_shadow_example.webp
202+
:align: center
203+
:alt: Font shadow example
204+
205+
Font shadow example
206+
207+
.. tip::
208+
209+
You can create local overrides to font display in Label nodes by creating a
210+
:ref:`class_LabelSettings` resource that you reuse across Label nodes. This
211+
resource takes priority over :ref:`theme properties <doc_gui_skinning>`.
212+
159213
Advanced font features
160214
----------------------
161215

@@ -297,6 +351,23 @@ The downsides of MSDF font rendering are:
297351
`Google Fonts <https://fonts.google.com>`__, try downloading the font from the
298352
font author's official website instead.
299353

354+
.. figure:: img/using_fonts_rasterized_vs_msdf_comparison.webp
355+
:align: center
356+
:alt: Comparison of font rasterization methods
357+
358+
Comparison of font rasterization methods.
359+
From top to bottom: rasterized without oversampling, rasterized with oversampling, MSDF
360+
361+
To enable MSDF rendering for a given font, select it in the FileSystem dock, go
362+
to the Import dock, enable **Multichannel Signed Distance Field**, then click
363+
**Reimport**:
364+
365+
.. figure:: img/using_fonts_msdf_import_options.webp
366+
:align: center
367+
:alt: Enabling MSDF in the font's import options
368+
369+
Enabling MSDF in the font's import options
370+
300371
.. _doc_using_fonts_emoji:
301372

302373
Using emoji
-2.69 KB
Binary file not shown.

0 commit comments

Comments
 (0)