Posted on 11:30 AM
In this tutorial I will show you how to generate and import bitmap fonts in Unity3D with ShoeBox and GlyphDesigner.
Usually, it’s safe to keep bitmap fonts below 50 megabytes, otherwise the extension may crash. The font size will grow depending on the size and also the complexity of the glyphs (how many colors, whether there are textures, etc.). Then let’s have some more fun Create a color font. Go to Window Extensions Fontself Maker. BitFonter is a professional bitmap font editor for Windows (with limited capabilities to run on macOS up to 10.14 Mojave as well, not on 10.15 Catalina). With BitFonter, you can create and edit bitmap fonts for print publications, web pages, animations, computer games and electronic devices.
UPDATE 07.07.2016: An Unity asset store plugin can convert your bitmap fonts for free: https://github.com/lite3/Unity-BitmapFontImporter
UPDATE 11.17.2015: Littera is an online tool. It works great and it’s free: http://kvazars.com/littera/
UPDATE: Unity 5.x, I updated the script but there is an issue with the space interline.
Create a professional bitmap logo in minutes with our free bitmap logo maker. BrandCrowd logo maker is easy to use and allows you full customization to get the bitmap logo you want! Change colours, fonts, add a tagline Our bitmap logo maker is 100% customizable and easy to use. Download your bitmap logo! Download your bitmap logo. Bitmap Font Generator This program will allow you to generate bitmap fonts from TrueType fonts. The application generates both image files and character descriptions that can be read by a game for easy rendering of fonts. The program is freeware and open source, but a donation is greatly appreciated. Yet another bitmap font generator. Utility for create texture atlases with bitmap chars from FreeType,TrueType and some other font formats. Current state: alpha. Downloads: from github Support: gamedev.ru forum theme (russian) Program features that make it outstanding comparing to other programs: distrubution method (open source,MIT License).
EDIT: GitHub repository
You can use your own custom font in your Unity games like this:
First of all we need to export a .xml file and a .png file.
You will also need this piece of code to generate a font compatible with Unity. I modified and found this C# script in the Unity forum.
Download and add this C# script in your Unity Assets folder: GitHub zip
The softwares
It exists several applications to export a bitmap font with a .xml file but in this tutorial we will use ShoeBox and GlyphDesigner:
- ShoeBox: Free, Adobe Air required
- GlyphDesigner: Shareware, Mac, Windows
- Littera: Free, Online
- bmGlyph: Shareware, Mac
- etc.
Export a bitmap font with ShoeBox
ShoeBox is a free Adobe Air based app for Windows and Mac OSX with game and ui related tools. Each tool uses a drag and drop or clipboard interaction for a quick workflow.
How to generate the required files to import your custom font with ShoeBox?
- Download and Install ShoeBox: http://renderhjs.net/shoebox/
- You can use my custom font in this .psd file: MyCustomFont.psd
- Watch this video bellow but export with the template: FNT-xml Starling. Yes! Starling! :). The BitmapImporterScript.cs script needs a .XML file format.
The video tutorial:
- Import the .xml and the .png files in your Unity Assets folder.
Follow the next step of the tutorial in the next chapter after this one.
Export a bitmap font with GlyphDesigner
Glyph Designer is a powerful bitmap font designer. Create beautiful designs using highly configurable effects, definable backgrounds and more. Make the most of your screen with smart zooming and full screen support. Target hundreds of devices on multiple platforms with support for over 15 frameworks out the box. Streamline localizations with GDCL.
How to generate the required files to import your custom font with GlyphDesigner?
- Download and install GlyphDesigner for Mac or Windows
- Create your own custom bitmap font with all the glyphs you need
- Click on the Export button
- And select Export Type > .xml (BMFont XML)
- Click Save
- Import the .xml and the .png files in your Unity Assets folder.
Follow the next step of the tutorial in the next chapter.
Import and use the bitmap font in Unity
- Import the BitmapFontImporter.cs file in your Unity Assets folder.
- Then do a Right Click on the .xml file
- Click Generate Bitmap Font
- The Script should generate a .material and a .fontsettings file
- Now we use the font you just created in your scene
- Create an UI > Text game object in your scene
- Select the UI Text game object
- In the inspector go to the Text(Script) component and add the .fontsettings file in the Character >Font field
- Then add the .mat file in the Material field
- Never use the Font Size value in the component but use the Scale of the game object instead
One of the big problems OpenGL runs into after you’ve got your first few polygons flying around the screen is the lack of a standard method for generating text within the API.
A few techniques have evolved to tackle the problem:
Pre-generated string textures
The simplest and fastest method, a texture is pre-built for each piece of text that needs to be displayed. This is quick to render at run time, but isn’t very flexible or efficient.
Polygon glyphs created from outline font definitions
This method produces high quality, scalable text, but this is also the slowest approach due to the overhead of generating and rendering the glyph polygons.
WGL and GLUT extensions
These extensions do a great job of text rendering. However, these libraries are not universally available on all systems and I have a bad habit of trying to be portable and platform independent.
Bitmapped fonts
Bitmap fonts are fast, flexible and platform independent. However, there are some limitations: Quality suffers when scaling up the texture and the number of possible characters in a font bitmap is limited. Extended or Unicode character sets with accents or non-latin symbols are not well supported.
A bitmapped font is simply an atlas texture containing a collection of glyphs and symbols. (Note: the purple lines are a visual aid, they do not appear on the actual texture.)
The grid layout means that the calculation required to select any given character is quick and simple.
The area containing the selected characters can then be mapped onto a series of polygons to create dynamic strings of text.
Adding width information to the glyphs allows the textured quads to be overlapped to create better looking text with variable character widths.
There are quite a few bitmap font generators around, but I couldn’t find one that provided all the features I wanted. So I wrote my own.
Codehead’s Bitmap Font Generator (CBFG) is now at version 1.45 and supports the following features:
- DIB rendering of font gives best font output, regardless of users screen settings
- Global or per character position and width adjustment
- Texture Sizes from 16×16 up to 4096×4096
- Zoom up to 400% for accurate tweaking of character positions
- Anti-aliasing or ClearType (XP+) for smoother looking fonts
- Control of font width
- Font preview option
- TGA export option
- BMP output option
- BFF output in 8, 24 and 32bit colour depths
- C++ example source code for loading and rendering BFF files
- Binary font data export
- Font info dump option
- User configurable colours and startup parameters
Many people have made useful suggestions that have been implemented in CBFG, and the tool has been used on the following projects:
- Floating Sandbox A 2D Physics Simulator developed by Gabriele Giuseppini.
- Beginning Android Games An APress book by Robert Green and Mario Zechner
- SkaPong by Einar
- SF2DBmpFont a font loader for 3DS homebrew by Flarn2006
- ByVac’s [BV4629] Touchscreen LCD
Downloads
CBFG Packages
Windows Installer Package
Files only zip
Source Code
See Full List On Angelcode.com
CBFG has been open sourced under the BSD licence. You can get v1.45 on GitHub
BFF Loading Code
C/C++ - included in zip/installer.
Bitmap Font Creator
Android by Codehead
O’Caml by Einar (local mirror)
SF2DBmpFont a font loader for SF2DLib by Flarn2006
The Future
CBFG hasn’t been in active development for a few years now, but there are still a few features I always wanted to add:
ToDo List
Reference
- State save option
- Merge/Extract font image
Wish List
- Export in other font generator formats
- Edit font image
- Unicode support
Known Issues
Windows Bitmap Font
Cleartype system setting can override antialias settings in application.
Comments are closed.