Text Rendering in Unity with Bitmap Fonts
A couple of trimesters ago I started writing a tool that allowed rendering of text using bitmap fonts. Text rendering in this way was particularly popular on older and more limited systems, such as early arcade machines and consoles up until around the sixth generation when vector fonts became the norm. With that being said, there are still many instances where one would prefer to use this type of text renderer. Bitmap fonts consist of a texture divided up into a grid, with each cell representing a character. This makes it very easy for any developer to create a font quickly or achieve a retro text art style if desired.
The other reason for writing this tool was that I found the UI system in Unity 4x somewhat cumbersome, I wanted a solution that was fast, simple and easy to configure. Despite Unity 5 having introduced new modules for handling UI, I decided to finish the tool for the same reasons mentioned above. I've tried to replicate various aspects of Unity's already included text components, to keep the workspace looking familiar while remaining simple enough for my liking. The tool allows text to be rendered in either local or world space and is entirely configurable in regards to character orientation and alignment.
Bitmap fonts characters may be laid out in a texture of arbitrary size, providing that they are in powers of two and are laid out sequentially as to represent the ASCII standard. Support for textures of varying sizes is achieved by being able to specify the number of characters in each row aka number of columns. Above is an example bitmap font in the form of a 256x256 texture laid out as a 16x16 grid of characters, flowing from left to right and top to bottom. Here is a link to the source code, just save the script into Unity's assets folder and access it from the component menu under UI/Bitmap Font Text.
The other reason for writing this tool was that I found the UI system in Unity 4x somewhat cumbersome, I wanted a solution that was fast, simple and easy to configure. Despite Unity 5 having introduced new modules for handling UI, I decided to finish the tool for the same reasons mentioned above. I've tried to replicate various aspects of Unity's already included text components, to keep the workspace looking familiar while remaining simple enough for my liking. The tool allows text to be rendered in either local or world space and is entirely configurable in regards to character orientation and alignment.
Bitmap fonts characters may be laid out in a texture of arbitrary size, providing that they are in powers of two and are laid out sequentially as to represent the ASCII standard. Support for textures of varying sizes is achieved by being able to specify the number of characters in each row aka number of columns. Above is an example bitmap font in the form of a 256x256 texture laid out as a 16x16 grid of characters, flowing from left to right and top to bottom. Here is a link to the source code, just save the script into Unity's assets folder and access it from the component menu under UI/Bitmap Font Text.
Comments
Post a Comment