-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Fonts from the SVG-Font format
--   
--   Native font support for the diagrams framework
--   (<a>http://projects.haskell.org/diagrams/</a>). Note that this package
--   can be used with any diagrams backend, not just the SVG backend. The
--   SVG-font format is easy to parse and was therefore chosen for a font
--   library completely written in Haskell.
--   
--   You can convert your own font to SVG with
--   <a>http://fontforge.github.io/</a>, or use the included LinLibertine
--   and Bitstream fonts.
--   
--   Features:
--   
--   <ul>
--   <li>Complete implementation of the features that Fontforge produces
--   (though not the complete SVG format)</li>
--   <li>Kerning (<i>i.e.</i> the two characters in "VA" are closer than
--   the characters in "VV")</li>
--   <li>Unicode</li>
--   <li>Ligatures</li>
--   <li>An example that shows how to do text boxes with syntax
--   highlighting using highlighting-kate:
--   <a>http://hackage.haskell.org/package/highlighting-kate</a></li>
--   </ul>
--   
--   XML speed issues can be solved by trimming the svg file to only those
--   characters that are used (or maybe binary xml one day).
--   
--   Version 1.0 of this library supports texturing, though this only makes
--   sense in a diagrams backend that does rasterization in Haskell, such
--   as diagrams-rasterific.
--   
--   Example:
--   
--   <pre>
--    # LANGUAGE NoMonomorphismRestriction #
--   
--   main = do linLibertine &lt;- loadDataFont "fonts/LinLibertine.svg"
--             t &lt;- text'''' linLibertine "Hello"
--             mainWith (t :: Diagram B)
--   
--   text'   font t = stroke (textSVG t 1) # fc purple # fillRule EvenOdd
--   text''  font t = stroke (textSVG' (TextOpts font INSIDE_H KERN False 1 1) t) # fillRule EvenOdd
--   text''' font t =        (textSVG_ (TextOpts font INSIDE_H KERN True  1 1) t) # fillRule EvenOdd
--   
--   -- using a local font
--   text'''' font t = do
--      font &lt;- loadFont "/path/to/font.svg"
--      return $ stroke (textSVG' (TextOpts font INSIDE_H KERN False 1 1) t)
--   </pre>
@package SVGFonts
@version 1.7

module Graphics.SVGFonts.CharReference

-- | Parsing of xml character references.
--   
--   I.e. "&amp;#x2e;&amp;#x2e;&amp;#x2e;" is converted into a list of
--   three Chars.
--   
--   "ffb" is also parsed and converted into three Chars (not changing it).
charsFromFullName :: String -> String

-- | A string represents a glyph, i.e. the ligature "ffi" is a string that
--   represents the ligature glyph ffi
characterStrings :: String -> [String] -> [Text]


-- | Parsing the SVG path command, see
--   <a>http://www.w3.org/TR/SVG/paths.html#PathData</a> :
module Graphics.SVGFonts.ReadPath

-- | Convert a SVG path string into a list of commands
pathFromString :: Fractional n => String -> Either String [PathCommand n]
pathFromByteString :: Fractional n => ByteString -> Either String [PathCommand n]
data PathCommand n

-- | Establish a new current point (with absolute coords)
M_abs :: !(n, n) -> PathCommand n

-- | Establish a new current point (with coords relative to the current
--   point)
M_rel :: !(n, n) -> PathCommand n

-- | Close current subpath by drawing a straight line from current point to
--   current subpath's initial point
Z :: PathCommand n

-- | A line from the current point to (n, n) which becomes the new current
--   point
L_abs :: !(n, n) -> PathCommand n
L_rel :: !(n, n) -> PathCommand n

-- | A horizontal line from the current point (cpx, cpy) to (x, cpy)
H_abs :: !n -> PathCommand n
H_rel :: !n -> PathCommand n

-- | A vertical line from the current point (cpx, cpy) to (cpx, y)
V_abs :: !n -> PathCommand n
V_rel :: !n -> PathCommand n

-- | Draws a cubic Bézier curve from the current point to (x,y) using
--   (x1,y1) as the ^control point at the beginning of the curve and
--   (x2,y2) as the control point at the end of the curve.
C_abs :: !(n, n, n, n, n, n) -> PathCommand n
C_rel :: !(n, n, n, n, n, n) -> PathCommand n

-- | Draws a cubic Bézier curve from the current point to (x,y). The first
--   control point is assumed to be the reflection of the second control
--   point on the previous command relative to the current point. (If there
--   is no previous command or if the previous command was not an C, c, S
--   or s, assume the first control point is coincident with the current
--   point.) (x2,y2) is the second control point (i.e., the control point
--   at the end of the curve).
S_abs :: !(n, n, n, n) -> PathCommand n
S_rel :: !(n, n, n, n) -> PathCommand n

-- | A quadr. Bézier curve from the curr. point to (x,y) using (x1,y1) as
--   the control point
Q_abs :: !(n, n, n, n) -> PathCommand n

-- | Nearly the same as cubic, but with one point less
Q_rel :: !(n, n, n, n) -> PathCommand n

-- | T_Abs = Shorthand/smooth quadratic Bezier curveto
T_abs :: !(n, n) -> PathCommand n
T_rel :: !(n, n) -> PathCommand n

-- | A = Elliptic arc (not used)
A_abs :: PathCommand n
A_rel :: PathCommand n
instance GHC.Show.Show n => GHC.Show.Show (Graphics.SVGFonts.ReadPath.PathCommand n)

module Graphics.SVGFonts.ReadFont

-- | This type contains everything that a typical SVG font file produced by
--   fontforge contains.
data FontData n
FontData :: SvgGlyphs n -> Kern n -> [n] -> String -> n -> n -> Maybe n -> Maybe n -> Maybe n -> Maybe n -> n -> String -> String -> String -> String -> String -> Maybe String -> n -> String -> Maybe n -> n -> n -> n -> n -> Maybe n -> Maybe String -> Maybe n -> Maybe n -> String -> [(String, [String], [String], [String], [String])] -> Maybe n -> Maybe n -> Maybe n -> Maybe n -> Maybe n -> Maybe n -> Maybe n -> Maybe n -> FontData n
[fontDataGlyphs] :: FontData n -> SvgGlyphs n
[fontDataKerning] :: FontData n -> Kern n
[fontDataBoundingBox] :: FontData n -> [n]
[fontDataFileName] :: FontData n -> String
[fontDataUnderlinePos] :: FontData n -> n
[fontDataUnderlineThickness] :: FontData n -> n
[fontDataOverlinePos] :: FontData n -> Maybe n
[fontDataOverlineThickness] :: FontData n -> Maybe n
[fontDataStrikethroughPos] :: FontData n -> Maybe n
[fontDataStrikethroughThickness] :: FontData n -> Maybe n
[fontDataHorizontalAdvance] :: FontData n -> n
[fontDataFamily] :: FontData n -> String
[fontDataStyle] :: FontData n -> String
[fontDataWeight] :: FontData n -> String
[fontDataVariant] :: FontData n -> String
[fontDataStretch] :: FontData n -> String
[fontDataSize] :: FontData n -> Maybe String
[fontDataUnitsPerEm] :: FontData n -> n
[fontDataPanose] :: FontData n -> String
[fontDataSlope] :: FontData n -> Maybe n
[fontDataAscent] :: FontData n -> n
[fontDataDescent] :: FontData n -> n
[fontDataXHeight] :: FontData n -> n
[fontDataCapHeight] :: FontData n -> n
[fontDataAccentHeight] :: FontData n -> Maybe n
[fontDataWidths] :: FontData n -> Maybe String

-- | This data is not available in some fonts (e.g. Source Code Pro)
[fontDataHorizontalStem] :: FontData n -> Maybe n

-- | This data is not available in some fonts (e.g. Source Code Pro)
[fontDataVerticalStem] :: FontData n -> Maybe n
[fontDataUnicodeRange] :: FontData n -> String
[fontDataRawKernings] :: FontData n -> [(String, [String], [String], [String], [String])]
[fontDataIdeographicBaseline] :: FontData n -> Maybe n
[fontDataAlphabeticBaseline] :: FontData n -> Maybe n
[fontDataMathematicalBaseline] :: FontData n -> Maybe n
[fontDataHangingBaseline] :: FontData n -> Maybe n
[fontDataVIdeographicBaseline] :: FontData n -> Maybe n
[fontDataVAlphabeticBaseline] :: FontData n -> Maybe n
[fontDataVMathematicalBaseline] :: FontData n -> Maybe n
[fontDataVHangingBaseline] :: FontData n -> Maybe n

-- | Difference between highest and lowest y-value of bounding box
bbox_dy :: RealFloat n => FontData n -> n

-- | Lowest x-value of bounding box
bbox_lx :: FontData n -> n

-- | Lowest y-value of bounding box
bbox_ly :: FontData n -> n

-- | Position of the underline bar
underlinePosition :: FontData n -> n

-- | Thickness of the underline bar
underlineThickness :: FontData n -> n

-- | Horizontal advance of a character consisting of its width and spacing,
--   extracted out of the font data
horizontalAdvance :: String -> FontData n -> n

-- | Change the horizontal advance of two consective chars (kerning)
kernAdvance :: RealFloat n => String -> String -> Kern n -> Bool -> n

-- | See <a>http://www.w3.org/TR/SVG/fonts.html#KernElements</a>
--   
--   Some explanation how kerning is computed:
--   
--   In Linlibertine.svg, there are two groups of chars: e.g. &lt;hkern
--   g1="f,longs,uni1E1F,f_f" g2="parenright,bracketright,braceright"
--   k="-37" /&gt; This line means: If there is an f followed by
--   parentright, reduce the horizontal advance by -37 (add 37). Therefore
--   to quickly check if two characters need kerning assign an index to the
--   second group (g2 or u2) and assign to every unicode in the first group
--   (g1 or u1) this index, then sort these tuples after their name (for
--   binary search). Because the same unicode char can appear in several
--   g1s, reduce this <tt>multiset</tt>, ie all the ("name1",0) ("name1",1)
--   to ("name1",[0,1]). Now the g2s are converted in the same way as the
--   g1s. Whenever two consecutive chars are being printed try to find an
--   intersection of the list assigned to the first char and second char
data Kern n
Kern :: Map String [Int] -> Map String [Int] -> Map String [Int] -> Map String [Int] -> Vector n -> Kern n
[kernU1S] :: Kern n -> Map String [Int]
[kernU2S] :: Kern n -> Map String [Int]
[kernG1S] :: Kern n -> Map String [Int]
[kernG2S] :: Kern n -> Map String [Int]
[kernK] :: Kern n -> Vector n

-- | A map of unicode characters to outline paths.
type OutlineMap n = Map String (Path V2 n)

-- | A font including its outline map.
type PreparedFont n = (FontData n, OutlineMap n)

-- | Read font data from font file, and compute its outline map.
loadFont :: (Read n, RealFloat n) => FilePath -> IO (PreparedFont n)

-- | Read font data from an XmlSource, and compute its outline map.
loadFont' :: (XmlSource s, Read n, RealFloat n) => String -> s -> (String, PreparedFont n)
instance GHC.Generics.Generic (Graphics.SVGFonts.ReadFont.FontData n)
instance GHC.Generics.Generic (Graphics.SVGFonts.ReadFont.Kern n)
instance GHC.Show.Show n => GHC.Show.Show (Graphics.SVGFonts.ReadFont.Kern n)
instance Data.Serialize.Serialize n => Data.Serialize.Serialize (Graphics.SVGFonts.ReadFont.FontData n)
instance Data.Serialize.Serialize n => Data.Serialize.Serialize (Graphics.SVGFonts.ReadFont.Kern n)

module Graphics.SVGFonts.WriteFont
makeSvgFont :: (Show n, ToValue n) => PreparedFont n -> Set String -> Svg

module Graphics.SVGFonts.Fonts

-- | Bitstream, a standard monospaced font (used in gedit)
bit :: (Read n, RealFloat n) => IO (PreparedFont n)

-- | Linux Libertine, for non-monospaced text.
--   <a>http://www.linuxlibertine.org/</a> Contains a lot of unicode
--   characters.
lin :: (Read n, RealFloat n) => IO (PreparedFont n)

-- | Linux Libertine, cut to contain only the most common characters. This
--   results in a smaller file and hence a quicker load time.
lin2 :: (Read n, RealFloat n) => IO (PreparedFont n)

-- | Load a font from a file in the data directory.
loadDataFont :: (Read n, RealFloat n) => FilePath -> IO (PreparedFont n)

module Graphics.SVGFonts.Text
data TextOpts n
TextOpts :: PreparedFont n -> Mode -> Spacing -> Bool -> n -> n -> TextOpts n
[textFont] :: TextOpts n -> PreparedFont n
[mode] :: TextOpts n -> Mode
[spacing] :: TextOpts n -> Spacing
[underline] :: TextOpts n -> Bool
[textWidth] :: TextOpts n -> n
[textHeight] :: TextOpts n -> n
data Mode

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

-- | 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_W :: Mode

-- | 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.
--   
INSIDE_WH :: Mode

-- | See <a>http://en.wikipedia.org/wiki/Kerning</a>
data Spacing

-- | Every glyph has a unique horiz. advance
--   
HADV :: Spacing

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

-- | A short version of textSVG' with standard values. The Double value is
--   the height.
--   
--   <pre>
--   import Graphics.SVGFonts
--   
--   textSVGExample = stroke $ textSVG "Hello World" 1
--   </pre>
--   
textSVG :: (Read n, RealFloat n) => String -> n -> 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.
--   
--   <pre>
--   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
--   </pre>
--   
textSVG' :: RealFloat n => TextOpts n -> String -> Path V2 n

-- | 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.
--   
--   <pre>
--   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"
--   </pre>
--   
textSVG_ :: forall b n. (TypeableFloat n, Renderable (Path V2 n) b) => TextOpts n -> String -> QDiagram b V2 n Any
instance GHC.Show.Show Graphics.SVGFonts.Text.Spacing
instance GHC.Show.Show Graphics.SVGFonts.Text.Mode
instance (GHC.Read.Read n, GHC.Float.RealFloat n) => Data.Default.Class.Default (Graphics.SVGFonts.Text.TextOpts n)

module Graphics.SVGFonts

-- | A short version of textSVG' with standard values. The Double value is
--   the height.
--   
--   <pre>
--   import Graphics.SVGFonts
--   
--   textSVGExample = stroke $ textSVG "Hello World" 1
--   </pre>
--   
textSVG :: (Read n, RealFloat n) => String -> n -> 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.
--   
--   <pre>
--   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
--   </pre>
--   
textSVG' :: RealFloat n => TextOpts n -> String -> Path V2 n

-- | 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.
--   
--   <pre>
--   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"
--   </pre>
--   
textSVG_ :: forall b n. (TypeableFloat n, Renderable (Path V2 n) b) => TextOpts n -> String -> QDiagram b V2 n Any
data TextOpts n
TextOpts :: PreparedFont n -> Mode -> Spacing -> Bool -> n -> n -> TextOpts n
[textFont] :: TextOpts n -> PreparedFont n
[mode] :: TextOpts n -> Mode
[spacing] :: TextOpts n -> Spacing
[underline] :: TextOpts n -> Bool
[textWidth] :: TextOpts n -> n
[textHeight] :: TextOpts n -> n
data Mode

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

-- | 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_W :: Mode

-- | 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.
--   
INSIDE_WH :: Mode

-- | See <a>http://en.wikipedia.org/wiki/Kerning</a>
data Spacing

-- | Every glyph has a unique horiz. advance
--   
HADV :: Spacing

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

-- | Bitstream, a standard monospaced font (used in gedit)
bit :: (Read n, RealFloat n) => IO (PreparedFont n)

-- | Linux Libertine, for non-monospaced text.
--   <a>http://www.linuxlibertine.org/</a> Contains a lot of unicode
--   characters.
lin :: (Read n, RealFloat n) => IO (PreparedFont n)

-- | Linux Libertine, cut to contain only the most common characters. This
--   results in a smaller file and hence a quicker load time.
lin2 :: (Read n, RealFloat n) => IO (PreparedFont n)

-- | Read font data from font file, and compute its outline map.
loadFont :: (Read n, RealFloat n) => FilePath -> IO (PreparedFont n)

-- | Load a font from a file in the data directory.
loadDataFont :: (Read n, RealFloat n) => FilePath -> IO (PreparedFont n)
