Appendix E. Creating Fonts

The fonts built into the system that renders your SVG documents will take care of the vast majority of your needs. Sometimes, though, you will want to use a custom font. It is possible to create a font for use with SVG from scratch. In brief, you use a <font> element tag to describe the origin and default width of the font’s glyphs. Inside the <font> is the <font-face> element, which has an immense number of attributes that describe the font’s dimensions in excessive detail. These attributes are summarized in the SVG specification at http://www.w3.org/TR/SVG/fonts.html. Following the <font-face> are <glyph> elements, which contain path descriptions for each of the glyphs you wish to have in your font.

While it is possible to create fonts from scratch, it’s a lot of work, and often a duplication of effort, since the glyphs you need may be in an already-existing font. If you already have a True Type font with the desired glyphs, you are in luck.

The ttf2svg Utility

The Apache Batik project has created a utility that will convert your True Type fonts to SVG. The following summary is adapted from the Batik project’s documentation and is Copyright (C) 2000 The Apache Software Foundation. All rights reserved.

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 developer distribution, type the following at the command line:

build ttf2svg [options]

In both cases, ...

Get SVG Essentials now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.