SVGFonts-1.8.0.1: Fonts from the SVG-Font format
Safe HaskellNone
LanguageHaskell2010

Graphics.SVGFonts.Text

Synopsis

Setting text as a path using a font.

data TextOpts n Source #

Constructors

TextOpts 

Instances

Instances details
(Read n, RealFloat n) => Default (TextOpts n) Source # 
Instance details

Defined in Graphics.SVGFonts.Text

Methods

def :: TextOpts n #

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

Instances details
Show Spacing Source # 
Instance details

Defined in Graphics.SVGFonts.Text

horizontalAdvances :: RealFloat n => [String] -> FontData n -> Bool -> [n] Source #

Horizontal advances of characters inside a string. A character is stored with a string (because of ligatures like "ffi").

data PreparedText n Source #

Constructors

PreparedText 

Fields

  • fontTop :: n

    y position of font top.

  • fontBottom :: n

    y position of font bottom (usually negative unless the characters are fully above baseline).

  • preglyphs :: [(String, n)]
     

prepare :: RealFloat n => TextOpts n -> String -> PreparedText n Source #

Break text into preglyphs (= ligatures and singleton characters) and compute their advances.

draw_glyphs :: RealFloat n => TextOpts n -> [(String, n)] -> [Path V2 n] Source #

Create a path (glyph) for each preglyph.

shift_glyphs :: RealFloat n => [(n, Path V2 n)] -> [Path V2 n] Source #

Position glyphs according to their advances.

svgText :: RealFloat n => TextOpts n -> String -> PathInRect n Source #

Render PathInRect from text. The enclosing rectangle, computed from the font, is kept, to be able to e.g. correctly position lines of text one above other.

svgText_raw :: RealFloat n => TextOpts n -> String -> Path V2 n Source #

Simply render path from text.

svgText_modifyPreglyphs :: (RealFloat n, Monad m) => TextOpts n -> (PreparedText n -> m [(String, n)]) -> String -> m (PathInRect n) Source #

Like svgText but preglyphs can be modified using the given monad before draw_glyphs is called. Simple examples of this function's specializations are e.g. svgText_fitRect and svgText_fitRect_stretchySpace.

svgText_fitRect :: forall n. RealFloat n => TextOpts n -> (n, n) -> String -> PathInRect n Source #

Like svgText but a rectangle is provided, into which the text will fit. The text is scaled according to the height of the rectengle. The glyphs are interleaved with even spaces to fit the width of the rectangle. The text must have at least two characters for correct functionality.

svgText_fitRect_stretchySpace :: forall n. RealFloat n => TextOpts n -> (n, n) -> n -> String -> PathInRect n Source #

Like svgText_fitRect but space characters are stretched k times more than others for svgText_fitRect_stretchySpace opts (w, h) k text.

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