SVGFonts-1.6.0.2: Fonts from the SVG-Font format

Safe HaskellNone
LanguageHaskell2010

Graphics.SVGFonts

Contents

Synopsis

Drawing text

textSVG :: (Read n, RealFloat n) => String -> n -> Path V2 n #

A short version of textSVG' with standard values. The Double value is the height.

import Graphics.SVGFonts

textSVGExample = stroke $ textSVG "Hello World" 1

textSVG' :: RealFloat n => TextOpts n -> String -> Path V2 n #

Create a path from the given text and options. The origin is at the center of the text and the boundaries are given by the outlines of the chars.

import Graphics.SVGFonts

text' t = stroke (textSVG' (TextOpts lin INSIDE_H KERN False 1 1) t)
           # fc blue # lc blue # bg lightgrey # fillRule EvenOdd # showOrigin

textPic0 = (text' "Hello World") # showOrigin

textSVG_ :: forall b n. (TypeableFloat n, Renderable (Path V2 n) b) => TextOpts n -> String -> QDiagram b V2 n Any #

Create a path from the given text and options. The origin is at the left end of the baseline of of the text and the boundaries are given by the bounding box of the Font. This is best for combining Text of different fonts and for several lines of text. As you can see you can also underline text by setting underline to True.

import Graphics.SVGFonts

text'' t = (textSVG_ (TextOpts lin INSIDE_H KERN True 1 1) t)
           # fc blue # lc blue # bg lightgrey # fillRule EvenOdd # showOrigin

textPic1 = text'' "Hello World"

Options

data TextOpts n #

Constructors

TextOpts 

Instances

(Read n, RealFloat n) => Default (TextOpts n) # 

Methods

def :: TextOpts n #

data Mode #

Constructors

INSIDE_H

The string fills the complete height, width adjusted. Used in text editors. The result can be smaller or bigger than the bounding box:

INSIDE_W

The string fills the complete width, height adjusted. May be useful for single words in a diagram, or for headlines. The result can be smaller or bigger than the bounding box:

INSIDE_WH

The string is stretched inside Width and Height boundaries. The horizontal advances are increased if the string is shorter than there is space. The horizontal advances are decreased if the string is longer than there is space. This feature is experimental and might change in the future.

Instances

Show Mode # 

Methods

showsPrec :: Int -> Mode -> ShowS #

show :: Mode -> String #

showList :: [Mode] -> ShowS #

data Spacing #

Constructors

HADV

Every glyph has a unique horiz. advance

KERN

Recommended, same as HADV but sometimes overridden by kerning: As You can see there is less space between "A" and "V":

Instances

Provided fonts

bit :: (Read n, RealFloat n) => PreparedFont n #

Bitstream, a standard monospaced font (used in gedit)

lin :: (Read n, RealFloat n) => PreparedFont n #

Linux Libertine, for non-monospaced text. http://www.linuxlibertine.org/ Contains a lot of unicode characters.

lin2 :: (Read n, RealFloat n) => PreparedFont n #

Linux Libertine, cut to contain only the most common characters. This results in a smaller file and hence a quicker load time.

Loading fonts

loadFont :: (Read n, RealFloat n) => FilePath -> IO (PreparedFont n) #

Read font data from font file, and compute its outline map.