forked from frogatto/frogatto
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFONT_GENERATION
83 lines (62 loc) · 2.98 KB
/
FONT_GENERATION
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
=====================
Font Generation Guide
=====================
Audience
--------
This guide is for translators or developers interested in adding
automatically generated Frogatto font textures so that it can support a
new language, or updating an existing font texture to reflect changes
to a translation.
Background
----------
Currently Frogatto uses, instead of TrueType or fonts in other common
formats, bitmap font textures -- images containing the rendering of
each character, plus FML files describing the location of each glyph in
the image.
Frogatto uses four groups of fonts: numbers, dialog, label and
outline, where "number" is used for floating number popups, score and
coin amounts, "dialog" for dialog lines, "label" for button labels,
and "outline" mainly for the title screen tips. The font generation
system only deals with the latter three, and refers to them as "styles".
The "number" font is not included in the automatic generation because
it can be usually reused in any language.
The reason why an automatic font texture generation system is needed
is because certain languages, such as Chinese and Japanese, have huge
"alphabets", so it is infeasible to manually draw all the characters
for them within a short amount of time.
Requirements
------------
The system requires a *nix environment, Ruby 1.9, and ImageMagick.
Usage
-----
The font generation system should be used when a new language with
a huge alphabet is added, or when the translation for an existing
such language is updated. In either case, the system only requires
access to a TrueType font and the po file for the language.
Before using the system, it may be needed to edit the top section of
Rakefile.fonts, to specify fonts used in each language.
To use the system, simply run::
rake fonts
Which will perform all the needed tasks based on the configured
languages. You can also selectively run tasks; use the following
to see how::
rake -T
Implementation
--------------
The system mainly works in three steps: extracting a list of characters,
generating a glyph image for each character, and generating a font
texture. The first step is done for each language, while the next two
steps are done for each language and font style.
This is a "make" like system, which avoids repeating completed work by
checking the modification timestamps of existing files. For example,
if a translation is updated and uses 5 new characters, then only the
glyphs for these characters will be generated and the font texture will
be generated. To force regeneration of a file, delete the file, or "touch"
one of its dependent files, before running the system.
The files used or generated by the system are listed below, in an order
showing their inter-dependencies:
* po/<locale>.po: translation file
* tmp/fonts/<locale>/characters.txt: list of characters
* tmp/fonts/<locale>/{dialog,outline,label}/<codepoint>.png: glyph image
* images/gui/{dialog,outline,label}_font.<locale>.png: font texture
* data/fonts.<locale>.cfg: glyph location data