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