SVGFonts-1.6.0.1: Fonts from the SVG-Font format

Safe HaskellNone
LanguageHaskell2010

Graphics.SVGFonts.Text

Contents

Synopsis

Setting text as a path using a font.

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

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"