Difference between revisions of "Fonts"

From Open Surge Engine Wiki
Jump to: navigation, search
(Created page with '== Overview == Fonts are used to display texts in Open Surge. They are described by .fnt files located in the fonts/ folder and they can be classified in two types: * Bitmap fon…')
 
m
Line 30: Line 30:
 
  }
 
  }
  
* '''source_file''' is the file where the engine should grab the characters
+
* '''source_file''' is the file where the engine should grab the characters
* '''source_rect''' describes a rectangle in the image (x-position, y-position, width and height). The entire set of characters are contained in this rectangle
+
 
* '''frame_size'' is the size of each character in the rectangle above
+
* '''source_rect''' describes a rectangle in the image (x-position, y-position, width and height). The entire set of characters are contained in this rectangle
* '''keymap''' is the association between the image and their respective characters (from left to right, top to bottom)
+
 
 +
* '''frame_size'' is the size of each character in the rectangle above
 +
 
 +
* '''keymap''' is the association between the image and their respective characters (from left to right, top to bottom)
  
 
=== True-Type ===
 
=== True-Type ===

Revision as of 03:28, 25 December 2010

Overview

Fonts are used to display texts in Open Surge. They are described by .fnt files located in the fonts/ folder and they can be classified in two types:

  • Bitmap fonts
  • True-Type fonts

.fnt files are human-readable: they can be opened with any simple text editor like Notepad or gedit.

Font types

Bitmap

Bitmap fonts are fixed-width fonts. Essentially, you provide to Open Surge an image containing lots of characters, all of them having the same size. Besides, you tell the engine which characters correspond to each block in the image. Working that way, whenever you want the engine to display some text, it will read your font definition and copy the correct blocks in your image to the screen, hence drawing the text you need.

Suppose the image below is stored in images/smallfont.png:

Smallfont.png

You may then open a simple text editor and save the following script to fonts/smallfont.fnt:

font "small"
{
    bitmap
    {
        source_file             "images/smallfont.png"
        source_rect             0 0 128 72
        frame_size              8 12
        keymap                  " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_\x60abcdefghijklmnopqrstuvwxyz{|}~"
    }
}
  • source_file is the file where the engine should grab the characters
  • source_rect describes a rectangle in the image (x-position, y-position, width and height). The entire set of characters are contained in this rectangle
  • 'frame_size is the size of each character in the rectangle above
  • keymap is the association between the image and their respective characters (from left to right, top to bottom)

True-Type