Ziafont

Ziafont reads TrueType/OpenType font files and draws characters and strings as SVG <path> elements. Unlike the SVG <text> element, the output of Ziafont’s SVG will render identically on any system, independent of whether the original font is available. However, the SVG will not be text-searchable, as characters are replaced by curves.

Ziafont supports fonts with TrueType glyph outlines contained in a “glyf” table in the font (these fonts typically have a .ttf extensions), or fonts with a “CFF “ table (typically with a .otf extension). Kerning adjustment is supported if the font has a “GPOS” table, and ligature substitution is supported if the font has a “GSUB” table.

Example

import ziafont
font = ziafont.Font('NotoSerif-Regular.ttf')
font.text('Ziafont!')
_images/index_0_0.svg
s = font.text('Z').svg()
print(s[:80])  # Just show 80 characters here...
<svg xmlns="http://www.w3.org/2000/svg" width="28.406" height="34.266" viewBox="

Installation

Ziafont can be installed using pip:

pip install ziafont

No dependencies are required.


Demo

See Ziafont in action as it runs in your browser through PyScript here!

Ziafont is used by the Ziamath and Ziaplot Python packages.


Support

If you appreciate Ziafont, buy me a coffee to show your support!


Source code is available on Github.