# Simple text rendering

The following complete example creates a window that displays "Hello, World" centered vertically and horizontally:

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

    @window.event
    def on_draw():
        window.clear()
        label.draw()

    pyglet.app.run()

The example demonstrates the most common uses of text rendering:

- The font name and size are specified directly in the constructor. Additional parameters exist for setting the bold and italic styles and the color of the text.
- The position of the text is given by the `x` and `y` coordinates. The meaning of these coordinates is given by the `anchor_x` and `anchor_y` parameters.
- The actual text is drawn with the Label.draw method. Labels can also be added to a graphics batch; see Graphics for details.

The HTMLLabel class is used similarly, but accepts an HTML formatted string instead of parameters describing the style. This allows the label to display text with mixed style:

    label = pyglet.text.HTMLLabel(
        '<font face="Times New Roman" size="4">Hello, <i>world</i></font>',
        x=window.width//2, y=window.height//2,
        anchor_x='center', anchor_y='center')

See Formatted text for details on the subset of HTML that is supported.