vispy.visuals.text.text module#

class vispy.visuals.text.text.FontManager(method='cpu')#

Bases: object

Helper to create TextureFont instances and reuse them when possible

get_font(face, bold=False, italic=False)#

Get a font described by face and size

class vispy.visuals.text.text.SDFRendererCPU#

Bases: object

Render SDFs using the CPU.

render_to_texture(data, texture, offset, size)#
class vispy.visuals.text.text.TextVisual(text=None, color='black', bold=False, italic=False, face='OpenSans', font_size=12, pos=[0, 0, 0], rotation=0.0, anchor_x='center', anchor_y='center', method='cpu', font_manager=None, depth_test=False)#

Bases: Visual

Visual that displays text

Parameters:
textstr | list of str

Text to display. Can also be a list of strings. Note: support for list of str might be removed soon in favor of text collections.

colorinstance of Color

Color to use.

boldbool

Bold face.

italicbool

Italic face.

facestr

Font face to use.

font_sizefloat

Point size to use.

postuple | list of tuple

Position (x, y) or (x, y, z) of the text. Can also be a list of tuple if text is a list.

rotationfloat

Rotation (in degrees) of the text clockwise.

anchor_xstr

Horizontal text anchor.

anchor_ystr

Vertical text anchor.

methodstr

Rendering method for text characters. Either ‘cpu’ (default) or ‘gpu’. The ‘cpu’ method should perform better on remote backends. The ‘gpu’ method should produce higher quality results.

font_managerobject | None

Font manager to use (can be shared if the GLContext is shared).

depth_testbool

Whether to apply depth testing. Default False. If False, the text behaves like an overlay that does not get hidden behind other visuals in the scene.

property anchors#
property bold#
property color#

The color of the text

property face#
property font_size#

The font size (in points) of the text

property italic#
property pos#

The position of the text anchor in the local coordinate frame

property rotation#

The rotation of the text (clockwise, in degrees)

property text#

The text string

class vispy.visuals.text.text.TextureFont(font, renderer)#

Bases: object

Gather a set of glyphs relative to a given font name and size

This currently stores characters in a TextureAtlas object which uses a 2D RGB texture to store unsigned 8-bit integer data. In the future this could be changed to a GL_R8 texture instead of RGB when OpenGL ES 3.0+ is standard. Since VisPy tries to stay compatible with OpenGL ES 2.0 we are using an RGB texture. Using a single channel texture should improve performance by requiring less data to be sent to the GPU and to remote backends (jupyter notebook).

Parameters:
fontdict

Dict with entries “face”, “size”, “bold”, “italic”.

rendererinstance of SDFRenderer

SDF renderer to use.

property ratio#

Ratio of the initial high-res to final stored low-res glyph

property slop#

Extra space along each glyph edge due to SDF borders