Skip to content

TextraTypist Playground

raeleus edited this page Jul 19, 2022 · 35 revisions

TextraTypist is an advanced text rendering library created by Tommy Ettinger to be used with Scene2D. This enables the ability to mark text with font effects like bold, italics, and underlining. See TextraLabel as a replacement for Label. The library also includes a modified version of Rafa's TypingLabel for many typing effects.

TextraTypist Playground is a module of Skin Composer used to help construct the markup necessary for rendering a TextraLabel or TypingLabel. By following this guide, you will be able to use the utility to type your text, apply formatting, and then copy the resulting code to your own project.

Preparation

Using the latest version of Skin Composer, create a new project or open an existing one. If you wish to use your own fonts with TextraTypist, go to Project >> Fonts and create the fonts that you want to use. Note that TextraTypist only allows for up to 15 fonts in a single family, so Playground will only recognize the first 15 that you have created. These can be Bitmap or FreeType fonts.

To implement TextraTypist in your own libGDX project, follow the setup guide on GitHub. Create a TypingLabel and implement it in your UI layout. You will copy the text you create in Playground and paste it into this label.

Creating Text

To begin, go to Project >> TextraTypist Playground. You will be prompted to choose a Standard Font Family or a Skin Font Family.

image

The font family controls what fonts you will have available to you when you use Playground and indicate which fonts are going to be used in the Label.

  • Standard Font Family allows you to use the fonts bundled with TextraTypist. These are always available and easiest to implement. There are more font families available including distance field fonts, however these have been omitted from Playground for ease of use. It is an exercise for the user to implement these.

  • Skin Font Family is a family created from the fonts in your Skin Composer skin. The names that you have defined your fonts with will be used in the program. You must construct the font family in your project code in order for these names to work correctly in your game.

You will come to the "Home" screen of the TextraTypist Playground.

image

The menu buttons allow you to navigate through the different screens.

image

The Formatting Bar contains all the functions available for applying effects and formatting to your text.

image

The Code text area allows you to type your text and modify the formatting tokens on the fly.

image

The Preview label shows you a live preview of the TypingLabel. It is updated automatically and repeats the animation with every new key stroke in the Code text area.

image

Basic Formatting

Type text in the Code text area, then highlight the text that you want to modify.

image

Click the image button to apply bold.

Notice that tokens have been added to the beginning and end of the selection. That means the formatting will only apply to that selection.

image

image

Another technique is to single click where you want formatting to begin.

image

Then click the "B" button. This time, a single token has been added. All text from this point on will be bold.

image

image

You can combine various tokens to achieve multiple appearances very much like a typical rich text editor.

image

image


image Applies bold formatting, making the text look thicker and creates emphasis.

image Applies italics formatting, slanting the text and creating a different kind of emphasis.

image Superscript decreases the font size and elevates the text above the line. This is often used for exponents in math.

image Subscript decreases the font size and lowers the text below the line. This is often used in chemical formulas.

image Midscript decreases the font size and places text at the center of the line. This is an in-between of superscript and subscript.

image Applies underlining to the text. This can draw attention to a particular phrase. The line is created from the underscore character specified in the font.

image Applies a strikethrough to the text. This can invalidate a phrase without deleting it entirely. The line is created from the dash character specified in the font.

image Uppercase Mode makes all text appear as capital despite whatever case they are written in.

image Lowercase Mode makes all text appear as lowercase despite whatever case they are written in.

image Capitalize Each Word Mode capitalizes the first letter of each word despite whatever case they are written in.

image Resets all formatting and effects to the defaults of the label.

Alternatively, you can just type your own tokens if you happen to know the names. See the token documentation.

Effects

Click the image button to open the effects preview.

image

You can choose an effect from the select box.

image

You can change the values by typing a new one in the field or using the buttons to the right. The preview will update as you make changes.

image

java_Q5jcTv21Bx

Boolean values can be activated or deactivated by clicking on them.

image

For effects that require colors, click the swatch to open the color picker.

image

image

"Var" and "Event" take text input to link your typing animation with your game code.

image

Click "OK" to insert the token into the text. If you've made changes to the default values, the token will include your parameters.

image

Otherwise, the default token name will be used.

image

If you have a range of text selected, opening and closing tokens will be created.

image

image

Select the "Reset" effect to reset all effects to the default typing effect.

image

Refer to the TextraTypist documentation to learn more about effects and their parameters.

Fonts

Click "Select a font..." to open the font menu. The available fonts depend on the chosen font family when Playground was launched.

image

Choosing a font inserts the token into the text.

image

image

If you have a range of text selected, opening and closing tokens will be created.

image

image

Select "Default" to reset the font to the label's default font.

image

The function of fonts in your game is dependent on the correct font family being loaded and/or created in code. See the font section of the TextraTypist documentation.

Size

Click "Select a size..."

image

Choosing a size inserts the token into the text.

image

image

If you have a range of text selected, opening and closing tokens will be created.

image

image

You can change the size of the text to a more precise number by changing the value in the token. The size is capped at a maximum of 375%.

image

Select "Default" to reset the size to the label's default size.

image

The appearance of scaled fonts is dependent on the font chosen. If a font has been configured for distance field, it will scale up without any artifacts.

image

Traditional fonts will look blurry at larger scales.

image

Color

Click "Select a color..."

image

Choosing a named color will insert the corresponding color token into the text.

image

image

If you have a range of text selected, opening and closing tokens will be created.

image

image

Select "Default" to reset the color to the label's default color.

image

Choose "More colors..." to open the color picker.

image

image

You can mix a color using any of the available color models.

image

You can also enter a six or eight digit hexadecimal value in the field.

image

Or you can select a color from the swatches menu.

image

To store your currently mixed color for selection later, click the "+" button under "Custom".

image

image

You can drag your custom colors into your preferred order. Drag a custom color away to remove it.

image

Click "OK" to finalize your color selection. "Cancel" to exit the dialog.

Implementing Text

View the preview of your TypingLabel in the bottom portion of the window.

image

Click the image button to stop the label from automatically animating when the code is changed. This is good for long texts or when you intend to only use a TextraLabel. Clicking it again will re-enable the animation and play it over again.

Click the image button to choose a different background. It is best to test your text against a background that closely matches what will be seen in game.

image

Once you are satisfied with the result, click the image button under "Code". This copies the tokenized text to the clipboard.

In your code, prepare a TypingLabel or TextraLabel as specified in the TextraTypist documentation. Note that TextraLabel does not display animated typing effects.

image

Paste the text as a parameter to the constructor of your label. Ensure that the text is quoted and escaped correctly.

image

To copy the plain text version without tokens, return to TextraTypist Playground and click the image button under "Preview".

Finishing Up

To return to Skin Composer, click "File" and select "Quit to Skin Composer".

image

Note that your text is persisted when you return to the Playground, but it is not saved with your Skin Composer project. Custom colors, however, are persisted between all sessions.

Clone this wiki locally