TrueType TTF Font to SVG Converter Command Line is a software that can convert a single character in a TrueType font .ttf file into an SVG 'path' shape. You can use this software to extract characters from a .ttf file and save to vector SVG files easily. The TrueType Font to SVG (ttf2svg) application lets you convert a range of characters from a TrueType Font into the SVG font format.
TrueType TTF Font to SVG Converter Command Line has a redistribution license,
after you purchase it, you can include this software into your product and
distribute it along with your product to your customers royalty free.
TrueType TTF Font to SVG Converter Command Line highlight features:
* Support Command Line operation.
* Support all Windows systems.
* You can call it from your C++, PHP, C#, VB.NET, Delphi etc. program languages.
* ttf to svg converter converts ttf format font files to svg files.
* Standalone software, don't require any 3rd products.
* Fast conversion speed.
* Support all version of TrueFont .ttf files.
TrueType Font (.ttf)
This is a standard TrueType font format created by Apple Computer in 1989. The advantage of TTF so far has been its high level of pixel-to-letter display control. It has a vector format so it is easy to scale. TrueType format is currently used in operating systems from Apple to Microsoft.
Scalable Vector Graphics (.svg)
SVG is a markup language, scalable vector graphics, created by the World Wide Web Consortium (W3C), designed for the description of two-dimensional vectors and mixed / raster graphics in XML. Supports both animated and interactive graphics as well as declarative script. It does not support the description of three dimensional objects. The SVG base VML has formed markup languages and PGML.
### Use cases
The TrueType Font converter application is helpful to be able to embed font definitions in SVG files. This will ensure that the SVG document will look exactly the same on all platform by not relying on system fonts.
Note that users of the tool should make sure that they have the right to embed the font before embedding it in an SVG file and should refer to the font license for information. Note that TrueType Font files contain a flag that defines the "embeddability" of a font and there are tools for checking that flag.
### basic usage:
Let's say you have a TrueType font file, such as the popular FreeSans.ttf. Let's pull out the path information for the letter "B" and transform it into SVG, you can run following command line,
ttf2svg.exe -file file.ttf -type glyphindex -code 10 ] unicode_b.svg
the program will generate an SVG path out of the TrueType information for the character of Unicode U+0066 (the Latin letter B), something like this:
[path d='M 591,-180 Q 591,-150 580,-121 Q 569,-92 543,-63 ... Z /]
'M' is 'move to', and 'Q' is for Bezier curves. Open the resulting .svg file in a web browser and you will able to view it properly.
This TrueType Font TTF to SVG Converter Command Line software will extract a single character from a .ttf file and create a matching .svg file, you can reuse .svg file from your application easily.
The program is stable for basic use. It can output plain glyph shapes or it can also output 'debugging' information like the node points & lines.
### Command Line options:
ttf2svg.exe -file file.ttf -type unicode -code 0x0042
ttf2svg.exe -file file.ttf -type glyphindex -code 0x0042
ttf2svg.exe -file file.ttf -type glyphindex -code 10
ttf2svg.exe -file file.ttf -type glyphindex -code 10
ttf2svg.exe -$ XXXXXXXXXXXXXXXXX
-file argument is a truetype font filename.
-type argument indicates unicode or glyphindex to -code argument.
If -type is unicode, -code will be the Unicode codepoint number.
If -type is glyphindex, -code will be the glyphindex.
second argument is a Unicode codepoint number. For example:
ttf2svg.exe -file FreeSerif.ttf -type unicode -code 66 ] example2.svg
In the line above, 66 = unicode/ascii for the letter 'B'. You can use hexadecimal numbers as well. For example, the Cherokee Letter O has hexadecimal Unicode point 0x13A3:
ttf2svg.exe -file FreeSerif.ttf -type unicode -code 0x13A3 ] example2.svg
To view the resulting svg file, it is easiest to use a browser like Firefox. Go to 'file/open' and point it to your output file. Or type something like 'file:///tmp/x.svg' into your address bar. You can also get the Firefox addon that can auto-reload files when they change on disk.
Another option is to use svg view/edit programs like Inkscape.
### How does Truetype actually work then? How does this program work?
Truetype fonts consist of a group of characters layed out in a file. The truetype file format is very complicated, with various issues related to character sets, glyph indexes, duplicated positions, etc etc etc. font_to_svg uses the Freetype library to make it easy to deal with those problems and to load the file into memory.
Each character in the Truetype file has a sequence of 'contours', which are basically a sequence of curves and lines that form a single shape. Some contours count as the 'body' of the letter, while others are the 'holes' of a letter. The letter 'B' for example has a single contour for the 'outside' shape, and two 'hole' contours for the two inside shapes.
Truetype marks these contours in a special way - by the 'clockwise' ness of the order in which it lists the points that make up a contour. The contours that have their points in 'clockwise' order are considered 'solid' The contours that have their points listed in 'counter clockwise' (also called 'anti-clockwise') order are considered 'holes'. For example, imagine the letter 'o'. The points making up the 'outside' contour are listed in clockwise order, while the points making up the 'inside' contour are listed in counter-clockwise order.
But what type of points make up a contour? They are simple 2-dimensional Cartesian points with integer coordinates. The points for a contour are listed in order in the Truetype file. The curves and lines of a contour are drawn between the points using the rules of Bezier Curves. This means there are actually two different types of points - 'on the curve' points and 'off the curve' points. The 'on the curve' points actually have lines or curves coming out of them and/or touching them. 'Off the curve' curves represent the 'control' points between the 'on the curve' points.
Now, Truetype doesn't just use any old Bezier curve. It uses a type of Bezier called 'Quadratic', which consists of two endpoints 'on the curve' and one 'control point'.
Now, in Truetype there is a special feature in the way off-curve points are listed. If two are listed in a row, then there is actually a 'hidden' or 'implied' on-curve point at a position exactly halfway between them. font_to_svg does not draw these points but they are easy to imagine when looking at the debug code.
Now. How does font_to_svg do SVG output? It basically just copies the point and contour information in the TrueType file and splits it into SVG paths. The actual rendering of the SVG file to something on a computer screen is left to the SVG rendering programs, like web browsers or Inkscape. The most complicated thing that these renderers do is probably the "non-zero winding rule", which is a geometry rule that determines how to properly draw the 'holes' and 'body' contours of a character glyph. font_to_svg doesn't have to worry about that either - it just inserts the svg property 'non-zero' fill-type into the generated SVG and the SVG renderer should take care of the rest.