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