Skip to content

TextLegibility ​

Inherits: Node

Description ​

Makes Label3D text bolder as it gets smaller on screen, so it stays legible at a distance instead of fading into a gray blur.

Thin strokes narrower than a pixel get blended with the background. A same-colored outline thickens every stroke; with MSDF fonts it is computed from the glyph's distance field, so it is cheap (one extra pass on the same atlas) and doesn't change the text layout. Only labels that have no outline of their own (outline_size == 0) and use an MSDF font are managed.

Properties ​

NameTypeDefault
_labelsDictionary{}

Methods ​

ReturnsName
Font_label_font ( label: Label3D )
FontFile_msdf_font ( font: Font )
Variant_on_node_added ( node: Node )
void_ready ( )
Dictionary_settings ( label: Label3D )
Variant_update ( _delta: float )

Constants ​

FULL_SIZE_ANGLE = 0.015 ​

Apparent em size (font_size * pixel_size / distance, in radians) at and above which text gets no extra weight. 0.015 = an 18mm em seen from 1.2m.

ICON_FONT = <Object> ​

Icon glyphs fill their em with much thinner strokes than letters, so they are treated as if their em were this much smaller.

ICON_SIZE_FACTOR = 0.5 ​

No description provided yet.

MAX_WEIGHT_OF_MSDF_RANGE = 0.95 ​

Upper bound as a fraction of the em. MSDF fonts can only draw outlines up to msdf_pixel_range / (2 * msdf_size) before artifacts (0.21 for Montserrat, 0.18 for the icons); the per-font limit is this fraction of that.

META_SETTINGS = "_text_legibility" ​

No description provided yet.

WEIGHT_PER_STEP = 0.11 ​

Outline added per unit of (FULL_SIZE_ANGLE / angle - 1), as a fraction of the em. Tuned so an 18mm em at 3m gets an outline of ~3 font pixels (0.17 em).

Property Descriptions ​

_labels: Dictionary ​

Label3D -> true. Labels leave the set when freed or taken out of the tree; node_added puts them back if they re-enter.

Method Descriptions ​

_label_font (label: Label3D ) -> Font ​

Same lookup as Label3D: own font, else the project theme / custom font, else the engine fallback.

_msdf_font (font: Font ) -> FontFile ​

The underlying FontFile if it renders as MSDF, else null.

_on_node_added (node: Node ) -> Variant ​

No description provided yet.

_ready ( ) -> void ​

No description provided yet.

_settings (label: Label3D ) -> Dictionary ​

Per-label settings, recomputed when the label's font changes (e.g. a button switching to its icon font). Only labels without their own outline, in an MSDF font, are managed.

_update (_delta: float ) -> Variant ​

No description provided yet.