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