pygfx.materials.TextMaterial
- class pygfx.materials.TextMaterial(color='#fff', *, outline_color='#000', outline_thickness=0, weight_offset=0, aa=True, **kwargs)
Bases:
Material
Basic text material.
- Parameters:
color (Color) – The color of the text.
outline_color (Color) – The color of the outline of the text.
outline_thickness (int) – A value indicating the relative width of the outline. Valid values are between 0.0 and 0.5.
weight_offset (int) – A value representing an offset to the font weight. Font weights are in the range 100-900, so this value should be in the same order of magnitude. Can be negative to make text thinner. Default zero.
aa (bool) – If True, use anti-aliasing while rendering glyphs. Aliasing gives prettier results, but may affect performance for very large texts.
kwargs (Any) – Additional kwargs will be passed to the
material base class
.
Notes
One use-case for weight_offset is to make dark text on a light background 50 units thicker, to counter the psychological effect that such text looks thinner than a light text on a dark background.
- property aa
Whether or not the glyphs should be anti-aliased. Aliasing gives prettier results, but may affect performance for very large texts. Default True.
- property color
The color of the text.
- property color_is_transparent
Whether the color is (semi) transparent (i.e. not fully opaque).
- property outline_thickness
A value indicating the relative width of the outline. Valid values are between 0.0 and 0.5. Default 0 (no outline).
- property outline_color
The color of the outline of the text.
- property outline_color_is_transparent
Whether the outline_color is (semi) transparent (i.e. not fully opaque).
- property weight_offset
A value representing an offset to the font weight. Font weights are in the range 100-900, so this value should be in the same order of magnitude. Can be negative to make text thinner. Default zero.
One use-case is to make dark text on a light background 50 units thicker, to counter the psychological effect that such text looks thinner than a light text on a dark background.