User Tools

Site Tools


Sidebar

Current version: 0.8.1
iOS: 0.8.1+
Android: 0.8.0.1+ (Play/Market version is obsolete!)

Github Coding has become social! Fork us!


News

Latest commit

https://github.com/gemrb/gemrb/commits/master

# ideally, but does not work on sourceforge (does elsewhere); even http proxies don't help rss>https://github.com/gemrb/gemrb/commits/master.atom 1 author 30m sidebar for frequently accessed stuff

plugins:ttf

TrueType Font Plugin

About Fonts in GemRB

Fonts in GemRB (as well as original IE games), aren't fonts in the traditional sense. The fonts are actually a simple sprite with each glyph rendered in order (ie A-Z). Image resources for these sprites are stored in IE BAM files. Implications of this method are:

  1. Fonts are fixed size
  2. Fonts take more memory the more characters they contain
  3. Fonts take more memory the larger they are
  4. Fonts cannot effectively be manipulated after creation (aside from changing the color palette)
  5. You are stuck using the fonts included with the game or modding your own
  6. Fonts cannot be kerned etc. (TTF fonts support basic kerning)

TrueType Fonts in GemRB

Technically TrueType fonts aren't limited in the same ways as “BAM” fonts. However, in order to support most of what TTF is capable of an that is important without having to write a new font renderer/breaking BAM support, TTF fonts in GemRB are done as Sprites in the same manner as the original fonts. What this means is that while the fonts are static once created we can supply parameters at engine start to create them in any size and any style supported by any TTF font you have available.

The TTF plugin for GemRB requires these libraries:

  • iconv (only needed if using a non unicode compatible dialog.tlk)

fonts.2da

Inside GemRB's “unhardcoded” folder there are subfolders for each game type which contain fonts.2da files for each game. These files tell GemRB how to construct fonts for a given “resref”.

2DA V1.0
NORMAL	
	RESREF		NEED_PALETTE	FONT_NAME	PT_SIZE		STYLE	COLOR
0	NORMAL		1		NORMAL		14		0	0xffffffff
1	INFOFONT	1		INFOFONT	14		0	0xffffffff
2	NUMBER		0		NUMBER		14		0	0xffffffff
3	INITIALS	0		INITIALS	14		0	0xffffffff
4	NUMBER2		0		NUMBER2		14		0	0xffffffff
5	NUMBER3		0		NUMBER3		14		0	0xffffffff
6	NUMFONT		1		NUMFONT		14		0	0xffffffff
7	REALMS		0		REALMS		14		0	0xffffffff
8	REALMS2		1		REALMS2		14		0	0xffffffff
9	STONEBIG	0		STONEBIG	14		0	0xffffffff
10	STONESM2	0		STONESM2	14		0	0xffffffff
11	STONESM3	0		STONESM3	14		0	0xffffffff
12	STONESML	0		STONESML	14		0	0xffffffff
13	TOOLFONT	1		TOOLFONT	14		0	0xffffffff
14	STATES  	0		STATES		14		0	0xffffffff
15	STATES2 	0		STATES2		14		0	0xffffffff

The columns: FONT_NAME, PT_SIZE, and STYLE are for TTF fonts only. FONT_NAME is the file name (NOT the path) of the TTF font you wish to use, and PT_SIZE controls the size of the font. STYLE controls the font style and accepts the following values:

  • 0=NORMAL
  • 1=BOLD
  • 2=ITALIC
  • 3=UNDERLINE

COLOR is the RGBA hexadecimal color to use to create the color palette. It applies to BAM fonts only if NEED_PALETTE is set. It applies to TTF fonts regardless of the value of NEED_PALETTE

GemRB config

In GemRB.cfg you must specify the following option (or copy the fonts to GamePath/override):

  • CustomFontPath is a string indicating the absolute path of the directory containing the non-BAM font files you wish to use. FONT_NAME must match a file name in this directory (without extension and may be case sensitive).

You may mix and match BAM and TTF fonts however you like.

Support for non-ASCII (multibyte) languages

TODO: move this section somewhere else (its own page?)

If you have a multibyte encoded dialog.tlk; you will have to add the Encoding setting to your gemrb.cfg. Set Encoding = to your language and make sure that an ini file matching your language exists under unhardcoded/shared. If no ini file matching your language exists, one must be created.

The TTF plugin must be either compiled with iconv support, or you must convert your dialog.tlk (tools/tlk_convert.py) to UTF-8 to use a non-Unicode compatible dialog.tlk/font.

To create your own language.ini, make a new text file like this (Chinese example):

[encoding]
TLKEncoding = GBK

Consult the encodings page to learn what encoding your dialog.tlk is in.

After you have a working language.ini, you should be able to play using either Unicode compatible TTF fonts or the BAM fonts supplied with your language pack.

In case the original strings are in a different encoding and you want to use common fonts, you can use tools/tlk_convert to convert them to utf-8 first.

plugins/ttf.txt · Last modified: 2014/02/02 08:40 by avenger