SVGFonts: Fonts from the SVG-Font format

[ bsd3, graphics, library ] [ Propose Tags ] [ Report a vulnerability ]

Native font support for the Diagrams library. The SVG-Font format is easy to parse and was therefore chosen for a font library completely written in Haskell.

You can convert your own font to SVG with http://fontforge.sourceforge.net/ or use the included LinLibertine, Bitstream

Features

  • Complete implementation of the features that Fontforge produces (but not the complete SVG format)

  • Kerning (i.e. the two characters in "VA" have a shorter distance than in "VV")

  • Unicode

  • Ligatures

  • An example that shows how to do text boxes with syntax highlighting using highlighting-kate: . http://hackage.haskell.org/package/highlighting-kate-0.5.3.8

XML speed issues can be solved by trimming the svg file to only those characters that are used (or maybe binary xml one day).

Version 1.0 of this library supports texturing which would only make sense in a Diagrams Backend that does rasterization in Haskell.

Example:

 # LANGUAGE NoMonomorphismRestriction #

import Diagrams.Prelude
import Diagrams.Backend.Cairo.CmdLine
import Graphics.SVGFonts.ReadFont (textSVG)


main = defaultMain (text' "Hello World")

text'   t = stroke (textSVG t 1) # fc purple # fillRule EvenOdd
text''  t = stroke (textSVG' $ TextOpts t lin INSIDE_H KERN False 1 1 ) # fillRule EvenOdd
text''' t =        (textSVG_ $ TextOpts t lin INSIDE_H KERN True  1 1 ) # fillRule EvenOdd

[Skip to Readme]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1, 0.2, 0.3, 0.4, 1.0, 1.1, 1.1.1, 1.1.2, 1.2, 1.2.1, 1.3, 1.3.0.1, 1.3.0.2, 1.4, 1.4.0.1, 1.4.0.2, 1.4.0.3, 1.5.0.0, 1.5.0.1, 1.6.0.0, 1.6.0.1, 1.6.0.2, 1.6.0.3, 1.7, 1.7.0.1, 1.8, 1.8.0.1
Dependencies attoparsec, base (>=4 && <5), containers (>=0.4 && <0.6), data-default, diagrams-lib (>=0.6), directory (>=1.1), parsec, split, text, tuple, vector, vector-space, xml [details]
License BSD-3-Clause
Author Tillmann Vogt
Maintainer diagrams-discuss@googlegroups.com
Category Graphics
Source repo head: git clone https://github.com/tkvogt/SVGFonts.git
Uploaded by TillmannVogt at 2013-04-09T12:54:19Z
Distributions LTSHaskell:1.8.0.1, NixOS:1.8.0.1, Stackage:1.8.0.1
Reverse Dependencies 11 direct, 12 indirect [details]
Downloads 36506 total (236 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs uploaded by user
Build status unknown [no reports yet]

Readme for SVGFonts-1.2.1

[back to package description]

SVGFonts

Native font support for the Diagrams library. The SVG-Font format is easy to parse and was therefore chosen for a font library completely written in Haskell.

You can convert your own font to SVG with http://fontforge.sourceforge.net/ or use the included LinLibertine, Bitstream.

Features

Complete implementation of the features that fontforge produces (but not the complete SVG format):

  • Kerning (i.e. the two characters in "VA" have a shorter distance than in "VV")
  • Unicode
  • Ligatures
  • Text boxes with syntax highlighting

XML speed issues can be solved by trimming the svg file to only those characters that are used (or maybe binary xml one day)

Version 1.0 of this library supports texturing which would only make sense in a Diagrams Backend that does rasterization in Haskell.

Example

{-# LANGUAGE NoMonomorphismRestriction #-}

import Diagrams.Prelude
import Diagrams.Backend.Cairo.CmdLine
import Graphics.SVGFonts.ReadFont

main = defaultMain ( (text' "Hello World") <> (rect 8 1) # alignBL )

text'  t = stroke (textSVG t 1) # fc purple # fillRule EvenOdd
text'' t = stroke (textSVG_ $ TextOpts t lin INSIDE_H KERN 1 1 )
             # fc purple # fillRule EvenOdd

Usage

Convert your favourite font (i.e. .ttf) into a .svg file with fontforge (the menu item under "Save All"). If a font converted on your own doesn't work, try the repair options, and if this still doesn't work edit the file by hand or tell me. Remember that a lot of fonts are not allowed to be distributed freely.