1 ttf2png - True Type Font to PNG converter
2 Copyright (c) 2004-2018 Mikko Rasa, Mikkosoft Productions
9 C compiler (preferably GCC)
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
21 Font size to use. The default is 10 pixels.
24 Number of glyphs to put in one line. Defaults to autodetect. Ignored
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.
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.
38 Force autohinter. By default native hinting is used if present in the
42 Render glyphs to alpha channel, with grey channel filled with white. By
43 default only the grey channel is used.
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
51 Increase the level of verbosity.
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.
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.
64 Leave a margin around the edges of the generated image. By default glyphs
65 can touch the edges. Only used with -p.
68 Control the amount of padding between glyphs. The default is 1 pixel.
72 File name to write glyph definitions. See the section below for details.
75 Print a help message with option summary.
78 Glyph definition files
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.
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.
88 The keyword "font" is followed by five fields with overall information about
89 the image and the font:
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
95 The keyword "glyph" is followed by eight fields describing a single glyph:
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
103 The keyword "kern" is followed by three fields describing kerning between two
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
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.
124 _ __x___|_______|___|____|__ baseline
126 v | o-------o | | descent
139 - Alternate ways of specifying code point ranges
142 - Controllable margin and padding in packed mode
143 - Do not generate overly large images in sequential grid mode
146 - Improve the packing algorithm
147 - Non-square cells for grid mode
148 - Option to invert colors
149 - Include kerning information in definition file
152 - Restructure the code
153 - Add tight packing mode
154 - Autodetect cell size and chars-per-line in grid mode
157 - Write both X and Y offsets of glyphs to the definition file
158 - Output font ascent and descent to definition file
161 - Don't create too large image with sequential mode if the range is sparse
164 - Added output to stdout
165 - Clean up code a bit
166 - Added sequential mode
167 - Added definition file writing
170 - Added more verbosity
171 - Added transparency mode
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.
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.
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.