aboutsummaryrefslogtreecommitdiff
path: root/builtin/common/serialize.lua
diff options
context:
space:
mode:
Diffstat (limited to 'builtin/common/serialize.lua')
0 files changed, 0 insertions, 0 deletions
n71' href='#n71'>71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145
# Font Lib API
This document describes Font Lib API. Font Lib creates textures for font display on entities.

## Settings
### default_font
Name of the font to be used when no font is given. The font should be registered.

If no default\_font given or if default\_font given but not registered, the first registered font will be used as default.

## Provided methods

### font_api.get_default_font_name()
Returns de default font name.

###font_api.register_font(font_name, font_def)
Register a new font.
**font_name**: Name of the font to register. If registering different sizes of the same font, add size in the font name (e.g. times_10, times_12...).
**font_def**: Font definition table (see **Font definition table** below).

###font_api.on_display_update(pos, objref)
Standard on_display_update entity callback.

**pos**: Node position

**objref**: Object reference of entity

Node should have a corresponding display_entity with size, resolution and maxlines fields and optionally halign, valign and color fields.

###Font definition table
Font definition table used by **font_api.register_font** and **font\_api.Font:new** may/can contain following elements:

* **height** (required): Font height in pixels (all font textures should have the same height) .
* **widths** (required): Array of character widths in pixels, indexed by UTF codepoints.
* **margintop** (optional): Margin (in texture pixels) added on top of each char texture.
* **marginbottom** (optional): Margin (in texture pixels) added at bottom of each char texture.
* **linespacing** (optional): Spacing (in texture pixels) between each lines.

**margintop**, **marginbottom** and **linespacing** can be negative numbers (default 0) and are to be used to adjust various font styles to each other.

Font must have a char 0 which will be used to display any unknown char.

All textures corresponding to the indexes in widths array should be present in textures directory with a name matching the pattern :

> font\_**{font_name}**_**{utf_code}**.png

**{font\_name}**: Name of the font as given in the first argument

**{utf\_code}**: UTF code of the char in 4 hexadecimal digits

Example : font_courrier_0041.png is for the "A" char in the "courrier" font.

To ease that declaration (specially to build the **widths** array), a shell is provided to build a {font\_name}.lua file from the texture files (see provided tools).

## Provided tools

Still in early stage of development, these tools are helpers to create font mods.