Apache > XML Federation > XML Graphics

Font Converter Utility

Creating SVG fonts


The True Type Font to SVG (ttf2svg) application lets you convert some character ranges from the True Type Font format to the SVG Font format.

This page describes:

Running the Font Converter

If you are using the Batik binary distribution, type the following at the command line:

java -jar batik-ttf2svg.jar [options]

If you are using the Batik source distribution, type the following at the command line:

build ttf2svg [options]

In both cases, the options are the same:

Options: <ttf-path> [-l <range-begin>] [-h <range-end>] [-ascii] [-id <id>] [-o <output-path>] [-testcard]


  • <ttf-path> specifies the True Type Font file containing the characters to be converted
  • [-l <range-begin>] [-h <range-end>] specify the low and high value of the range of characters to be converted to SVG.
  • [-ascii] forces usage of the ASCII character map
  • [-id <id>] specifies the value for the generated <font> element.
  • [-o <output-path>] specifies the path for the generated SVG Font file
  • [-testcard] specifies that a set of SVG <text> element should be appended to the SVG Font file to visualize and test the characters in the SVG Font. This provides an easy way to validate the generated SVG Font file visually

For example:

java -jar batik-ttf2svg.jar /usr/home/myFont.ttf -l 48 -h 57 -id MySVGFont -o mySVGFont.svg -testcard

Will convert characters 48 to 57, i.e., '0' to '9', in the myFont.ttf file into their SVG equivalent in the mySVGFont.svg file, appending a test card so that the font can be visualized easily.

Use Cases

The True Type 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 True Type Font files contain a flag that defines the 'embeddability' of a font and there are tools for checking that flag.

by Vincent Hardy