The FilterTexts property controls whether Texts are rendered. The TextManager can set this value and it will override the value set in the GraphicsOption's TextureFilter property.
The default for TextManager.FilterTexts is false, while the default value for the GraphicsOption's TextureFilter is on (technically it's an enumeration, but for simplicity we'll say that filtering does occur). The reason for this is because Text which is drawn to-the-pixel does not need to be filtered. Filtering text that is drawn to-the-pixel will make it look fuzzier than normal.
However, you may want to turn FilterTexts to true if you plan on drawing Texts at larger-than-pixel-perfect to reduce their pixellated look.
The following code creates a Text object and adds it to a layer.
Alternatively the Text can be added to a Layer after AddText is called. The following code can also be used:
The RemoveText method will remove the argument Text instance from the engine so it will no longer be drawn or have every-frame management applied. RemoveText also removes the Text from any PositionedObjectList that it is a part of (assuming a two-way relationship).
RemoveText can also remove entire lists:
For more information see AttachableLists.
The AddManuallyUpdated method adds the argument Text to the TextManager to be drawn. A manually updated Text does not have any of its ever-frame behavior performed by the TextManager, so changes to the Text must be manually applied. Manually updated Texts can be used in situations where a Text does not change after it has been created, or where only a small subset of properties change every frame, so manual updating can selectively update these variables for a performance boost.
The following code shows how to create 1000 manually updated Texts. It uses a large number of Text instances to show the performance benefit of using manually updated Texts.
On an i7 (in 2018) this code renders at around 464 frames per second, as shown in the following screenshot:
By contrast, calling AddText instead of AddManuallyUpdated results in a framerate of around 150 frames per second.
The ForceUpdateDependencies call is required to update a Text object according to its properties so that it renders properly. Normally this call is not needed because the engine calls it automatically, but in the code above we must call it after setting all properties to apply the values to the Text object. Notice that any changes made to the Text object after calling ForceUpdateDependencies will not apply on manually-updated Text instances. For example, changing the DisplayText after calling ForceUpdateDependencies will not change the string that the Text object is displaying.
FlatRedBall introduced a new method to the Text object: UpdateInternalRenderingVariables . This function will update the internal rendering values just like ForceUpdateDependencies without also updating the object according to its parent's position and rotation. Using UpdateInternalRenderingVariables can be slightly faster if the Text being updated is not attached to another object (such as an entity).
The TextManager is a static class which handles object addition, removal, and common behavior. The TextManager has many of the same methods (in concept) as the . The TextManager is automatically instantiated by FlatRedBall so you do not need to create an instance yourself.
The TextManager provides numerous methods for for working with the object. The following sections provide code samples for working with -related methods.
Most AddText methods both instantiate a new object as well as add it to TextManager for management. The following methods instantiate and add a object to the SpriteManager:
Custom can be used when creating objects as well.
For information see the .
Adding Text and Layers
objects can also be added to .
[subpages depth="1"]
For more information, see the and the .
The RemoveText methods remove objects from the engine as well as any (such as ) that the object belong to. For more information, see the .