# Text

{% hint style="info" %}
Text extends the Renderable class but has some unique methods that are listed below.

[Renderable Quick Reference](/quick-reference/renderable.md)\
[Text Documentation](https://pydraw.graphics/api/pydraw.html#pydraw.objects.Text)
{% endhint %}

## Initialization

Text can be initialized like this:

```python
text = Text(screen, text, x, y)
```

{% hint style="info" %}
There an extended constructor that contains most attributes, check the full documentation: [Text](https://pydraw.graphics/pydraw.html?highlight=text#pydraw.objects.Text)
{% endhint %}

## Text

You can get or change the text displayed with:

```python
text.text()  # Get the current text
text.text('new string!')  # Set new text
```

## Dimensions

pyDraw will automatically calculate a width and height once you've created a Text object (or when you update it's attributes), so you can get those values like so:

```python
text.width()
text.height()
```

## Font

You can access the font of the text with:

```python
text.font()  # The current font
text.font(font)  # Set a new font
```

## Size

You can also modify the font-size as expected:

```python
text.size()  # Retrieve the current font-size
text.size(16)  # Set a new font-size (~height in pixels)
```

{% hint style="warning" %}
The `width()` and `height()` methods will only return the height of the text created as they are determined by text, font, and font-size, and cannot be set.
{% endhint %}

## Align

You can specify an alignment for cases where multiple lines of text are given:

Possible Values (string):

* left
* center
* right

```python
text.align(alignment)
```

## Decorations

You can decorate text with the following methods:

```python
text.bold(True)
text.italic(True)
text.underline(True)
text.strikethrough(True)
```

##

##

##


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.pydraw.graphics/quick-reference/text.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
