Back

Illustration of text rendered with CTR.

Illustration of text rendered with CTR.
The text has been centered and it's rendered in multiple colors.

CTR - Custom Text Renderer

Overview

Hobby project

CTR on GitHub

CTR is a template project for Game Editor. Its purpose is to make easier to use text elements in games.

The built-in text elements in Game Editor are quite lacking in features. They can't be aligned right or centered and each text element can only feature a single color. Game Editor also fails to calculate the width and height of text elements correctly. The built-in text elements also don't support automatic line wrapping.

CTR solves these problems by basically redoing everything from the ground up. CTR doesn't utilize the built-in text elements of Game Editor at all. In CTR, each character is an individual game object (a clone), and the letters are actually just sprites, not glyphs of a font. This does place some limits on the accuracy of things such as kerning but I think the advantages gained significantly outweigh the disadvantages of the approach.

Font Tool

As CTR uses image fonts it comes shipped with a custom made tool for creating image fonts out of any font. The tool is built in Game Editor too.

The user inputs the name and size of the font they want to convert (it has to be a font available on the machine). The tool will then generate an .svg file containing the basic ASCII character set composed in such a way that it is very simple to export the collection of characters from Inkscape as a single spritesheet where the characters are arranged in a vertical column.

Screenshot of Font Tool, showing the basic setting controls and preview text.

Font Tool.

After generating the image font it can be imported back into the Font Tool for adjusting the settings of the font (letter spacing, word spacing, line spacing and indentation). The settings can be adjusted with a preview text showing the results in realtime. When the user is content with the results they can export the font data in one of 2 formats: code or data.

The code format produces a .c file with a Font struct (a custom data type used by CTR) initialized with the settings to be used with the font as well as the width of each of the characters in pixels.

The data format produces a binary file with the extension .fdf containing the settings to be used with the font as well as the width of each of the characters in pixels.

The code format is used by copying the contents of the file into Game Editor and the data file is used by loading the data with CTR API function readFontDataFile.

Some features of CTR

Below is a short showcase video of the features and usage of CTR.