Safe Haskell | None |
---|---|
Language | Haskell2010 |
- data TextOpts n = TextOpts {
- textFont :: PreparedFont n
- mode :: Mode
- spacing :: Spacing
- underline :: Bool
- textWidth :: n
- textHeight :: n
- data Mode
- data Spacing
- textSVG :: (Read n, RealFloat n) => String -> n -> Path V2 n
- textSVG' :: RealFloat n => TextOpts n -> String -> Path V2 n
- textSVG_ :: forall b n. (TypeableFloat n, Renderable (Path V2 n) b) => TextOpts n -> String -> QDiagram b V2 n Any
Setting text as a path using a font.
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. |
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"