]> git.tdb.fi Git - ttf2png.git/blob - Readme
Include kerning information in definition file
[ttf2png.git] / Readme
1 ttf2png - True Type Font to PNG converter
2 Copyright (c) 2004-2008  Mikko Rasa, Mikkosoft Productions
3
4
5 Software requirements
6
7 FreeType 2
8 libpng 1.2
9 C compiler (preferably GCC)
10
11
12 Command-line options
13
14   -r <low>,<high>
15     Range of characters to convert, specified as unicode code points.  The
16     default is 0,255, matching the ISO-8859-1 (Latin-1) character set.
17
18   -s <pixels>
19     Font size to use.  The default is 10 pixels.
20
21   -l <num>
22     Number of characters to put in one line.  Defaults to autodetect.  Ignored
23     if -p is used.
24
25   -c <pixels>
26     Character cell size.  The special values auto and autorect may be used to
27     choose an autodetected square or rectangle cell, respectively.  Defaults to
28     autodetected square.  Ignored if -p is used.
29
30   -o <filename>
31     Output file name.  Use - for stdout; the output is a png image, so it's
32     best to pipe it somewhere.  The default is font.png.
33
34   -a
35     Force autohinter.  By default native hinting is used if present in the
36     font.
37
38   -t
39     Render glyphs to alpha channel, with grey channel filled with white.  By
40     default only the grey channel is used.
41
42   -i
43     Invert colors of the glyphs.  When rendering to alpha channel, only the
44     alpha channel is inverted.
45
46   -v
47     Increase the level of verbosity.
48
49   -e
50     Use cells in sequence, without leaving gaps.  By default the position of
51     each glyph is determined by its code point.  Ignored if -p is used.
52
53   -p
54     Pack the glyphs tightly in the image.  One-pixel gaps are left between
55     glyphs.  By default glyphs are rendered in a regular grid.  Creating a
56     definition file is recommended, as the resulting image can seem rather
57     messy.
58
59   -d
60     File name to write glyph definitions.  See the section below for details.
61
62   -h
63     Print a help message with option summary.
64
65
66 Glyph definition files
67
68 Rendering a proportional font correctly requires some positioning and spacing
69 information, called font metrics.  To that end, ttf2png can write a definition
70 file alongside the image.
71
72 The basic format is line-based.  Empty lines, or those starting with a hash
73 sign (#), should be ignored.  Data lines consist of a keyword followed by
74 space-separated fields.
75
76 The keyword "font" is followed by five fields with overall information about
77 the image and the font:
78
79   Fields 1-2: width and height of the image
80   Field 3: nominal size of the font
81   Fields 4-5: ascent and descent of the font
82
83 The keyword "glyph" is followed by eight fields describing a single glyph:
84
85   Field 1: the code point of the glyph
86   Fields 2-3: x and y position of the glyph in the image
87   Fields 4-5: width and height of the glyph
88   Fields 6-7: x and y offset of the glyph from its base point
89   Field 8: advance from this glyph to the next
90
91 The keyword "kern" is followed by three fields describing kerning between two
92 glyphs:
93
94   Field 1: the code point of the left-hand glyph
95   Field 2: the code point of the right-hand glyph
96   Field 3: kerning distance between the glyphs
97
98 The following ASCII art image illustrates most of these metrics.  Note that in
99 some fonts, not all of the glyphs fit completely inside the character box.
100
101                 - - - - - - - -     ^
102                | character box |    |
103                                     |
104                |               |    |
105                    o-------o        | ascent
106                |   |       |   |    |
107                    | glyph |        |
108                |   |       |   |    |
109     base point     |       |        |
110              \ |   |       |   |    |
111               \    |       |        |
112            _ __x___|_______|___|____|__ baseline
113   y_offset |       |       |        |
114            v   |   o-------o   |    | descent
115                 - - - - - - - -     v
116            
117                |--->
118                x_offset
119
120                |--------------->
121                advance
122
123
124 Changelog
125
126 next
127 - Improve the packing algorithm
128 - Non-square cells for grid mode
129 - Option to invert colors
130 - Include kerning information in definition file
131
132 0.3
133 - Restructure the code
134 - Add tight packing mode
135 - Autodetect cell size and chars-per-line in grid mode
136
137 0.2.2
138 - Write both X and Y offsets of glyphs to the definition file
139 - Output font ascent and descent to definition file
140
141 0.2.1
142 - Don't create too large image with sequential mode if the range is sparse
143
144 0.2
145 - Added output to stdout
146 - Clean up code a bit
147 - Added sequential mode
148 - Added definition file writing
149
150 0.1.1
151 - Added more verbosity
152 - Added transparency mode
153
154 0.1
155 - Initial release
156
157
158 License
159
160 This program is free software; you can redistribute it and/or
161 modify it under the terms of the GNU General Public License
162 as published by the Free Software Foundation; either version 2
163 of the License, or (at your option) any later version.
164
165 This program is distributed in the hope that it will be useful,
166 but WITHOUT ANY WARRANTY; without even the implied warranty of
167 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
168 GNU General Public License for more details.
169
170 You should have received a copy of the GNU General Public License
171 along with this program; if not, write to the Free Software
172 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.