New text features

The pyglet.text module can render formatted text efficiently. A new class Label supercedes the old pyglet.font.Text class (which is now actually implemented in terms of Label). The "Hello, World" application can now be written:

window = pyglet.window.Window()
label = pyglet.text.Label('Hello, world',
                          font_name='Times New Roman',
                          x=window.width//2, y=window.height//2,
                          halign='center', valign='center')

def on_draw():

You can also display multiple fonts and styles within one label, with HTMLLabel:

label = pyglet.text.HTMLLabel('<b>Hello</b>, <font color=red>world!</font>')

More advanced uses of the new text module permit applications to efficiently display large, scrolling, formatted documents (for example, HTML files with embedded images), and to allow the user to interactively edit text as in a WYSIWYG text editor.