# TextManager

### Introduction

The TextManager is a static class which handles [Text](https://github.com/flatredball/FlatRedBallDocs/blob/main/frb/docs/index.php) object addition, removal, and common behavior. The TextManager has many of the same methods (in concept) as the [SpriteManager](https://github.com/flatredball/FlatRedBallDocs/blob/main/frb/docs/index.php). The TextManager is automatically instantiated by FlatRedBall so you do not need to create an instance yourself.

### Text Object

The TextManager provides numerous methods for for working with the [Text](https://github.com/flatredball/FlatRedBallDocs/blob/main/frb/docs/index.php) object. The following sections provide code samples for working with [Text](https://github.com/flatredball/FlatRedBallDocs/blob/main/frb/docs/index.php)-related methods.

### Text Addition

Most AddText methods both instantiate a new [Text](https://github.com/flatredball/FlatRedBallDocs/blob/main/frb/docs/index.php) object as well as add it to TextManager for management. The following methods instantiate and add a [Text](https://github.com/flatredball/FlatRedBallDocs/blob/main/frb/docs/index.php) object to the SpriteManager:

```
Text text = TextManager.AddText("FlatRedBall Rocks!"); // uses default font
```

Custom [BitmapFonts](https://github.com/flatredball/FlatRedBallDocs/blob/main/frb/docs/index.php) can be used when creating [Text](https://github.com/flatredball/FlatRedBallDocs/blob/main/frb/docs/index.php) objects as well.

```
BitmapFont bitmapFont = new BitmapFont("textureFile.png", "fontFile.txt", "content manager name");
Text text = TextManager.AddText("Text with custom font", bitmapFont);
```

For information see the [BitmapFont wiki entry](https://github.com/flatredball/FlatRedBallDocs/blob/main/frb/docs/index.php).

**Adding Text and Layers**

[Text](https://github.com/flatredball/FlatRedBallDocs/blob/main/frb/docs/index.php) objects can also be added to [Layers](https://github.com/flatredball/FlatRedBallDocs/blob/main/frb/docs/index.php).

```
 // Layers must be created through the SpriteManager
 Layer layer = SpriteManager.AddLayer();

 Text text = TextManager.AddText("I'm on a layer.", layer);
```

For more information, see the [Layer wiki entry](https://github.com/flatredball/FlatRedBallDocs/blob/main/frb/docs/index.php) and the [AddToLayer method](https://github.com/flatredball/FlatRedBallDocs/blob/main/frb/docs/index.php).

### Text Removal

The RemoveText methods remove [Text](https://github.com/flatredball/FlatRedBallDocs/blob/main/frb/docs/index.php) objects from the engine as well as any [two-way](https://github.com/flatredball/FlatRedBallDocs/blob/main/frb/docs/index.php#Two_Way_Relationships) [AttachableLists](https://github.com/flatredball/FlatRedBallDocs/blob/main/frb/docs/index.php) (such as [PositionedObjectList](https://github.com/flatredball/FlatRedBallDocs/blob/main/frb/docs/index.php)) that the [Text](https://github.com/flatredball/FlatRedBallDocs/blob/main/frb/docs/index.php) object belong to. For more information, see the [RemoveText page](https://github.com/flatredball/FlatRedBallDocs/blob/main/frb/docs/index.php).

### TextManager Members

\[subpages depth="1"]
