Font Documentation

M.U.G.E.N, (c) Elecbyte 1999-2009

Documentation for version 1.0 (2009)

Updated 18 September 2009

Overview

Fonts in M.U.G.E.N 1.0 are composed of a definition file with a "def" extension, and an accompanying sff or True Type font file. This format of font is referred to as FNT v2.

In versions prior to M.U.G.E.N 1.0, a font is represented as single binary file with a "fnt" extension. This format is referred to as FNT v1. M.U.G.E.N 1.0 is compatible with both formats of fonts.

This document describes the structure and format of FNT v2 font.

Terminology

Character
A single letter, number or symbol.
Glyph
The visualization of a single character.
Bitmap font
A font whose glyphs are represented entirely by sprites. Each character in the bitmap font's supported set maps to a sprite that is the glyph of that character.
TrueType font
A font whose glyphs are represented by vectors that describe how to render each glyph. TrueType fonts are commonly used in Microsoft Windows and other operating systems to render anti-aliased (smooth-looking) fonts for the user interface.
Color bank
A palette for a bitmap font that applies a color scheme to the glyphs. Fonts may contain one or more color banks.
Color bank number
A positive number that identifies a particular color bank.

FNT v2 def file

A required component of a font in FNT v2 format is the font definition file, which is a text file with a "def" extension. The font may be accompanied by a second file located in the same directory as the def file. What this file is depends on the type of font.

A FNT v2 font can either be a bitmap font or a TrueType font.

Bitmap fonts

An example bitmap font definition file, with inline comments, is shown below.

[FNT v2]
; FNT v2 version number.  Don't change this.
fntversion = 2,00
; Name of this font.
name = "4x6 variable"
; This font contains the full ASCII character set.
; All letters are uppercase.

[Def]
; This is a bitmap font
Type = bitmap
; Size of font: width, height.  Width is used for spaces.
Size = 3,6
; Spacing between font glyphs: width, height.
Spacing = 1,0
; Drawing offset: x, y.
Offset = 0,1
; Filename of the sff containing the glyphs.  Use sff v2 only.
File = f-4x6.sff

; Note: All units are in pixels.
; Text rendered with bitmap fonts may be in ASCII only.
; See work/font/f-4x6/f-4x6.def for information on creating the sff.

Only characters from the ASCII character set are supported by bitmap fonts. The extended ASCII set is not supported. For a table of the ASCII character set, see "ASCII character reference" below.

Bitmap fonts must be accompanied by an SFF file that contains the sprites for the glyphs. Each character in the font maps to a sprite indexed by 0,<ASCII code> where <ASCII code> is the corresponding ASCII code for the character. For example, the character 'A' (ASCII code 65) maps to sprite 0,65.

Any character which does not have a corresponding sprite will not be rendered.

Bitmap fonts may contain one or more color banks. Each color bank maps to a palette stored in the SFF, and indexed by 0,<color bank number> where <color bank number> is a positive number. If during font rendering, an invalid color bank is specified, the palette of the first sprite in the SFF will be used.

ASCII character reference

Printable characters are in the range 32-126. Only printable characters need to be represented as sprites.

=========  =========  =========  =========
Char  Dec  Char  Dec  Char  Dec  Char  Dec
---------  ---------  ---------  ---------
(nul)   0  (sp)   32  @      64  `      96
(soh)   1  !      33  A      65  a      97
(stx)   2  "      34  B      66  b      98
(etx)   3  #      35  C      67  c      99
(eot)   4  $      36  D      68  d     100
(enq)   5  %      37  E      69  e     101
(ack)   6  &      38  F      70  f     102
(bel)   7  '      39  G      71  g     103
(bs)    8  (      40  H      72  h     104
(ht)    9  )      41  I      73  i     105
(nl)   10  *      42  J      74  j     106
(vt)   11  +      43  K      75  k     107
(np)   12  ,      44  L      76  l     108
(cr)   13  -      45  M      77  m     109
(so)   14  .      46  N      78  n     110
(si)   15  /      47  O      79  o     111
(dle)  16  0      48  P      80  p     112
(dc1)  17  1      49  Q      81  q     113
(dc2)  18  2      50  R      82  r     114
(dc3)  19  3      51  S      83  s     115
(dc4)  20  4      52  T      84  t     116
(nak)  21  5      53  U      85  u     117
(syn)  22  6      54  V      86  v     118
(etb)  23  7      55  W      87  w     119
(can)  24  8      56  X      88  x     120
(em)   25  9      57  Y      89  y     121
(sub)  26  :      58  Z      90  z     122
(esc)  27  ;      59  [      91  {     123
(fs)   28  <      60  \      92  |     124
(gs)   29  =      61  ]      93  }     125
(rs)   30  >      62  ^      94  ~     126
(us)   31  ?      63  _      95  (del) 127
=========  =========  =========  =========

TrueType Fonts

An example TrueType font definition file, with inline comments, is shown below:

[FNT v2]
; FNT v2 version number.  Don't change this.
fntversion = 2,00
; Name of this font.
name = "Arial"
; Font author
author = "Microsoft"

[Def]
; This is a truetype font.
Type = truetype
; Size of font: width, height.  Only height is used for truetype fonts.
Size = 18,36
; Spacing between font glyphs.  Only height is used for truetype fonts.
Spacing = 1,1
; Drawing offset: x, y.
Offset = 0,0
; Filename of the font to load.  Will search Windows font directory if not in current directory.
File = arial.ttf
; Preferred blending mode: 0 - none, 1 - blended.
Blend = 1

; Note: All units are in pixels.
; Text rendered with truetype fonts may be ASCII or UTF-8

TrueType font definitions must be accompanied by a TrueType font file, which typically has an extension of .ttf or .ttc. If the TrueType font file is located in the same directory as the definition file, it will be loaded. Otherwise, M.U.G.E.N will attempt to load the font file from the Windows font directory.