Font collection (OpenXcom)

From UFOpaedia
Jump to: navigation, search

Font collection is bitmap fonts used by game engine to represent text.

Original UFO/TFTD engine uses two font types: big (BIGLETS.DAT, 16x16 pixels per character) and small (SMALLSET.DAT, 8x9 pixels per character) for Battlescape and Geoscape. But OpenXcom uses four font types: FontBig, FontGeoBig, FontSmall, FontGeoSmall. All of them described in *.dat file (which is actually YAML-file). Default font collection is placed in Language folder and named simply Font.dat.

Font.dat fonts (gray background used for transparent files)
FontBig.png
FontGeoBig.png
FontSmall.png
FontGeoSmall.png
FontBig.png FontGeoBig.png FontSmall.png FontGeoSmall.png


*.dat is divided in two sections: chars and fonts. chars is string which contain all available characters, provided by this font collection. font section is bit more complicated:

Value Description Default
id Type of charmap Should be FONT_BIG, FONT_SMALL, FONT_GEO_BIG, or FONT_GEO_SMALL
image Relative path to PNG-file with contains actual glyphes
width Width of a character
height Height of a character
spacing Spacing between two characters.

Each character in PNG-file have own rectangle with width and height. Characters shouldn't overlapping each other. Characters in *.png-file placed by groups with 16 characters in each group and ordered accordingly chars string. So if you want find actual character in *.png file, here formula:

y = (<number in chars> div 16) * height

x = (<number in chars> mod 16) * width

Here example for default Font.dat:

chars: >
  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖŐŰÙÚÛÜÝÞŸßàáâãäåæçèéêëìíîïðñòóôõöőűùúûüýþÿФИСВУАПРШОЛДЬТЩЗЙКЫЕГМЦЧНЯфисвуапршолдьтщзйкыегмцчнябБжЖхХъЪэЭюЮĆĘ깣泥ŚśźżŻŹŃńĂăȘȚșțČĎĚŇŘŠŤŮŽčďěňřšťůžЄєŒœіІїЇøØĞŞİğşıΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩαβγδεζηθικλμνξοπρστυφχψωΆΈΉΊΌΎΏάέήίόύώςΐϊĹĽŔĺľŕ∞Ёё
fonts:
  - id: FONT_BIG
    image: FontBig.png
    width: 16
    height: 16
    spacing: 0
  - id: FONT_SMALL
    image: FontSmall.png
    width: 8
    height: 9
    spacing: -1
  - id: FONT_GEO_BIG
    image: FontGeoBig.png
    width: 5
    height: 9
    spacing: 1
  - id: FONT_GEO_SMALL
    image: FontGeoSmall.png
    width: 5
    height: 7
    spacing: 1


Customizing

If you want customize font you can make it as mod. During initialization OpenXcom engine searches in Ruleset fontName string, which by default is Font.dat. You can redefine this string to another file, for example MyFont.dat, and replace some image strings to your *.png-files.

Just remember, *.dat file should be placed in Language folder, and *.png files are searched relative to *.dat file!