Unreal offers a complete world for you to roam -- a world of incredible beauty and realism with the most detailed environments ever to grace your PC screen. In one seamless flowing world, race across vast outdoor and indoor environments, enter enchanting cities, mysterious temples, glittering mines, shattered ships, and crystal clear waters. Unreal delivers this cutting-edge realism on computers using a Pentium 166 or higher. And for those of you lucky enough to have a Pentium II, MMX technology or a video accelerator, the Unreal realms will become your reality. Not that it’ll be easy: with Unreal's array of fierce new fully polygonal enemies stalking your every move, it’ll be a struggle just to survive. You’ll have some help, of course: with an arsenal of incredible new weapons at your disposal, you should at least have a fighting chance against the Skaarj and their allies. But with over 300 frames of animation apiece, and monster AI (that's Artificial Intelligence to...
This is a brief tutorial on how to make bitmap fonts manually and import them into Unreal Engine 1.x games like Unreal and UT99.
Posted by KynikossDragonn on Jan 20th, 2012
First off this is a rather tricky thing to accomplish in Unreal Engine. I don't truly understand how the font importer expects fonts to be laid out but so far I've manged to make a few minute fonts with only minor errors that can either be fixed easily towards you're better off scrapping and starting over.
Let's look at a example:
This is the Canvas object. It imports a few default fonts.
The #EXEC directive for importing bitmap fonts in Unreal Engine always follows this format:
#exec Font Import File=(path to file) Name=(object name)
Name can be ignored, if you omit the "Name=" field, the name is defaulted to the filename of the imported object. However this is for the FONT object, the texture that is the bitmap font will be called "Texture#" where # is a number. In both UnrealED 1.0 and 2.0+ Font's can be viewed but if you try to set the texture group in the texture browser to a font name it'll act as if you set it to (All). Also font's viewed this way do not show the grid of which the characters are arranged.
Here's what a typical font looks when viewed as a texture in UnrealED:
As you can see this is the default font in Unreal engine 1 games. Licensees may replace this font however.
Also as noted before you cannot see the grid of which the font is arranged but generally speaking you can get somewhat of a feel just by glancing at the already imported result how it sort of works.
For reference: In the editor as you view a font's texture the format of the object is as follows,
Now how do you make your own font you must be asking? It's simple!
Just fire up your favorite imaging editor that supports editing images in 256 colours along with being able to manually manipulate the palette. This is important as Index 0 in the palette is the masking colour while Index 255 is the font grid definer. For this reason I use Corel Paint Shop Pro but you can also obviously use Adobe Photoshop or similar. GIMP is not recommended as I found it does not manipulate 256 colour palette's properly wither this is a bug or a bad design choice I don't know but use at your own risk.
Before you start you need to have a ASCII table with you, this will tell you which glyphs to start first. If you try to just immediately start drawing the alphabet and align it to a grid, Unreal will not import it properly as it expects characters before A B C ,etc like spaces and numerals.
To start off and to show what the palette means let's export a font, and also observe a major pitfall in doing so:
You're probably wondering: "Where's the grid!?" That's right if you export a font texture after it has been imported as a font in Unreal Engine it strips the grid internally. However do not fret, there are usable font textures available in the beta demos that have the grid intact. And no using UTPT to export the font texture doesn't work. HOWEVER you can export the font table, how this is use to you I wouldn't know but it's useful for debugging if your font's not being defined properly.
Notice the deep blue colour at Index 255 this is used to define a font grid.
Now let's look at the MedFont of the past seeing how as I stated above the beta demo does not omit the font grid:
Notice the blue lines, this defines the glyphs in a font. Unreal bitmap fonts can be monospaced or proportional. When defining a font grid you should allow a extra bit of "white space" at the right side of a glyph so that it's spaced out when you're typing.
Unreal Engine reads fonts starting from the top left to the right and down. You should start with the Space character. This is 0x20 in hexadecimal, from there go with the ! " # ,etc until you get to the alphanumerics.
Now let's look at a font I made myself:
Note how I follow the same exact formatting. This is how Unreal expects glyphs to be lined out starting from 0x20 the space character and onward. Start at the top left of the image and work your way in a straight line to the right, when you run out of space, go to the bottom and work from there until you either fill the necessary characters you want or run out of space. Use a image that's power of two or it wont be importable into Unreal Engine at all.
BE SURE YOU ARE DRAWING YOUR FONT GRID WITH INDEX 255 OF YOUR COLOUR PALETTE!!!
Here's a UTPT font table export of my font:
Note how it begins at 0x20, that's the space character. X and Y is the position in the image itself where the top left portion of the grid point is located. Width and height is the propitiation of the glyph itself within the grid point. Use UTPT's "Export font" tool to determine if Unreal is not reading your font properly.
Reminder: Bitmap Font's will ALWAYS begin with 0x20. So start your grid off with the space character FIRST then work your way in order from the space character all the way to 0xFF, use an ASCII table to guide you on this. A typical font usually spans between 0x20 and 0x7E It's tricky to make a full fledged font that supports all extended ASCII codes, so experiment at your own peril with that. A full extended ASCII font is best left with the TTFImporter usually rather than making it manually yourself as a single bitmap.
For more information about ASCII read: En.wikipedia.org It includes a ASCII chart to assist you in crafting your font(s).
Here's a example grid:
In this example grid I wrote hexadecimal values for anything that's not usually typable on a standard US keyboard.
Notice how there's some omissions from the usual chart flow. This is because for some reason Unreal doesn't map to certain ASCII codes, so be sure when designing your font you follow the flow outlined in this example image or it may not import properly past the standard ASCII codes.
If all goes well your font should work perfectly in Unreal depending on how you engineered it for example:
This is the HUD to one of my custom PlayerPawn classes I've been developing over the months, it uses the RyukaFont I made from pasting together glyphs from the font used in Heretic\HeXen. As you can notice it only covers the standard typable ASCII range of 0x20 to 0x7E so no fancy non standard characters are used in the HUD.
Points to remember:
* Use: #exec Font Import File=(path to file) Name=(object name) to import bitmap fonts
* When designing the font grid start from TOP LEFT (0,0) and proceed right until you hit the extent you are able to draw another grid segment on. Then start over from below in the same manner as you did TOP LEFT.
* Unreal Engine does not assign all ASCII codes so don't try to make a full 0x00 to 0xFF font explicitly.
* Index 0 in the colour palette is the masking colour Index 255 is the grid defining colour.
* Bitmap Fonts can be monospace or proportional depending on how you design your font.
* ALWAYS START AT 0x20! ALWAYS END AT 0xFF!
* ALWAYS USE A POWER OF TWO TEXTURE!
I hope this is helpful to anyone who reads. Good luck making fonts manually instead of using TTFImporter like "everyone else".