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
18 UTF-8 characters. This option can be specified multiple times to add
19 more ranges to be converted.
22 Font size to use. The default is 10 pixels.
25 Number of glyphs to put in one line. Defaults to autodetect. Ignored
28 -c <pixels>[x<pixels>]
29 Character cell size. If only a single number is given, a square cell is
30 used. The special values auto and autorect may be used to choose an
31 autodetected square or rectangle cell, respectively. The default is auto.
32 Ignored if -p is used.
35 Output file name. Use - for stdout; the output is a png image, so it's
36 best to pipe it somewhere. The default is font.png.
39 Force autohinter. By default native hinting is used if present in the
43 Render glyphs to alpha channel, with grey channel filled with white. By
44 default only the grey channel is used.
47 Invert colors of the glyphs. When rendering to alpha channel, only the
48 alpha channel is inverted. The default is to render black glyphs on a
52 Increase the level of verbosity.
55 Use cells in sequence, without leaving gaps. By default the position of
56 each glyph is determined by its code point. Ignored if -p is used.
59 Pack the glyphs tightly in the image. Small gaps are left between glyphs,
60 controlled by the -n option. By default glyphs are rendered in a regular
61 grid. Creating a definition file is recommended, as the resulting image
62 can seem rather messy.
65 Leave a margin around the edges of the generated image. By default glyphs
66 can touch the edges. Only used with -p.
69 Control the amount of padding between glyphs. The default is 1 pixel.
73 Allow the resulting image to have a non-power-of-two size. By default the
74 image size is rounded up to a power of two for maximum compatibility.
77 File name to write glyph definitions. See the section below for details.
80 Print a help message with option summary.
83 Glyph definition files
85 Rendering a proportional font correctly requires some positioning and spacing
86 information, called font metrics. To that end, ttf2png can write a definition
87 file alongside the image.
89 The basic format is line-based. Empty lines, or those starting with a hash
90 sign (#), should be ignored. Data lines consist of a keyword followed by
91 space-separated fields.
93 The keyword "font" is followed by five fields with overall information about
94 the image and the font:
96 Fields 1-2: width and height of the image
97 Field 3: nominal size of the font
98 Fields 4-5: ascent and descent of the font
100 The keyword "glyph" is followed by eight fields describing a single glyph:
102 Field 1: the code point of the glyph
103 Fields 2-3: x and y position of the glyph in the image
104 Fields 4-5: width and height of the glyph
105 Fields 6-7: x and y offset of the glyph from its base point
106 Field 8: advance from this glyph to the next
108 The keyword "kern" is followed by three fields describing kerning between two
111 Field 1: the code point of the left-hand glyph
112 Field 2: the code point of the right-hand glyph
113 Field 3: kerning distance between the glyphs
115 The following ASCII art image illustrates most of these metrics. Note that in
116 some fonts, not all of the glyphs fit completely inside the character box.
129 _ __x___|_______|___|____|__ baseline
131 v | o-------o | | descent
144 - Alternate ways of specifying code point ranges
145 - Multiple code point ranges can be specified
146 - Option to generate non-power-of-two images
149 - Controllable margin and padding in packed mode
150 - Do not generate overly large images in sequential grid mode
153 - Improve the packing algorithm
154 - Non-square cells for grid mode
155 - Option to invert colors
156 - Include kerning information in definition file
159 - Restructure the code
160 - Add tight packing mode
161 - Autodetect cell size and chars-per-line in grid mode
164 - Write both X and Y offsets of glyphs to the definition file
165 - Output font ascent and descent to definition file
168 - Don't create too large image with sequential mode if the range is sparse
171 - Added output to stdout
172 - Clean up code a bit
173 - Added sequential mode
174 - Added definition file writing
177 - Added more verbosity
178 - Added transparency mode
186 This program is free software; you can redistribute it and/or
187 modify it under the terms of the GNU General Public License
188 as published by the Free Software Foundation; either version 2
189 of the License, or (at your option) any later version.
191 This program is distributed in the hope that it will be useful,
192 but WITHOUT ANY WARRANTY; without even the implied warranty of
193 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
194 GNU General Public License for more details.
196 You should have received a copy of the GNU General Public License
197 along with this program; if not, write to the Free Software
198 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.