SVGFonts-1.7: Fonts from the SVG-Font format

Graphics.SVGFonts

Synopsis

# Drawing text

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

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 Source #

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 Source #

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 Source #

Constructors

 TextOpts FieldstextFont :: PreparedFont n mode :: Mode spacing :: Spacing underline :: Bool textWidth :: n textHeight :: n

Instances

 (Read n, RealFloat n) => Default (TextOpts n) Source # Methodsdef :: TextOpts n #

data Mode Source #

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

 Source # MethodsshowsPrec :: Int -> Mode -> ShowS #show :: Mode -> String #showList :: [Mode] -> ShowS #

data Spacing Source #

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

 Source # MethodsshowList :: [Spacing] -> ShowS #

# Provided fonts

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

Bitstream, a standard monospaced font (used in gedit)

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

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

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

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