Check out our discord at https://discord.gg/3u69jMa 

True-Type Font Importing

From SWRC Wiki
Revision as of 02:12, 18 May 2024 by Plasma (talk | contribs)
Jump to navigation Jump to search

Copied from wayback machine, original source long gone!

Original Source: http://unreal.epicgames.com/TTFImport.htm

Wayback: http://web.archive.org/web/20090603183120/unreal.epicgames.com/TTFImport.htm


Jack Porter

Epic Games, Inc.

http://www.epicgames.com/


Audience: Licensees and mod-makers wanting to use Windows true-type fonts in the Unreal engine.

Last Updated: 08/10/99

Introduction

The TTF importer allows you to convert a Windows true-type font of a particular size into an Unreal font which you can then use to draw in-game text. The Unreal engine now has support for rendering anti-aliased fonts, and the TTF importer allows you to import the anti-aliasing from a Windows font.

Unreal has had the ability to import true-type fonts for use in-game since version 224, although there was a bug in the 224 font importer code which meant all the fonts you imported ended up as MS Sans Serif. Be sure you're using Unreal 225f or later, or you may have problems.

Importing Fonts into a .u File

You can import regular Unreal font textures into .u files using a #exec command, which instructs ucc make to import the font as the .u package is created. For example:

#exec Font Import File=Textures\MedFont.pcx Name=MedFont


Once the font is imported, you can refer to it as Font'MedFont' from inside UnrealScript.


To import a TTF, the true-type font first needs to be installed and accessible as a Windows font. If you've got a *.TTF file, you'll have to start by copying the font file into the Fonts control panel. Once this is done, you can import that TTF into a .u file, when ucc make creates the .u package, also by using a #exec command:

#exec new TrueTypeFontFactory Name=Tahoma30 FontName="Tahoma" Height=30 AntiAlias=1 CharactersPerPage=32


The Name parameter specifies the name of the font. In this case, I can refer to the font as Font'Tahoma30' from Script.

The FontName parameter specifies the Windows name of the font to be imported. For example "Comic Sans MS", "Arial" or "Earth Normal".

The Height parameter is the height of the font in pixels, which I give to Windows' CreateFont() API call.

If AntiAlias is 1, the TTF importer requests an anti-aliased font from Windows with the ANTIALIASED_QUALITY flag to CreateFont(). If it is 0, I pass NONANTIALIASED_QUALITY. See below for limitations of importing fonts with anti-aliasing.

The CharactersPerPage parameter specifies the number of characters per 256x256 pixel font texture. The default is 64. The TTF importer will give you an error if it runs out of space when drawing characters on the font pages. If you get the error "Font vertical size exceeded maximum of 256", you should half the CharactersPerPage parameter.

Two other parameters - XPad and YPad, add extra space between characters. These default to 1. Some fonts require extra space between characters, as Windows doesn't report their actual spacing requirement correctly.