FontRenderer converts a text to polygonal data using the outline of a specified font.
The source code can be obtained from GitHub.
The font file can be any file, that can be read and parsed by the FreeType 2 library. The font file must define a valid outline and thus a pixel based font map cannot be specified. Under Windows, any .ttf font file can be used. For many Linux distributions, font files can be found in /usr/share/fonts/truetype/.
In the resulting format multiple polygonal chains are specified. A polygonal chain always starts with the number of vertices followed by a list of vertices, one vertex per line. The vertices are specified as pairs of floating-point numbers separated by at least one white space character. See the example below for the letter L in “.line”-format.
Note, that polygonal chains are not automatically closed to form closed polygons. Thus, the first and last point of a polygonal chain have to match in order to regard the polygonal chain as a closed polygon. Also, note that the simplicity of the output is based on the definition of the font file and is neither checked nor guaranteed. From my observations I can conclude that simplicity can be assumed for high-quality-fonts.
FontRenderer can be used as follows.
fontrenderer [options] fontfile [input [output]]
The following example shows the use of this tool by rendering the rather simple letter L using the Liberation-Sans font.
$ echo L | ./fontrenderer /usr/share/fonts/truetype/liberation/LiberationSans-Regular.ttf
Execute the following commands in a shell:
tar xzf fontrenderer-1.1.1.tar.gz
In the build tree, change to the newly created directory bin/ and run the executable fontrenderer.
uname | ./fontrenderer /usr/share/fonts/truetype/liberation/LiberationSans-Regular.ttf
If you happen to find bugs, please report them.
Copyright © 2012 Dominik Kaaser
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the „Software“), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED „AS IS“, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.