Safe Haskell | Safe-Infered |
---|
- type Kern = (Map String [Int], Map String [Int], Map String [Int], Map String [Int], Vector Double)
- type SvgGlyph = Map String (String, Double, String)
- type FontData = (SvgGlyph, Kern, [Double], String)
- openFont :: FilePath -> FontData
- horizontalAdvances :: [String] -> FontData -> Bool -> [Double]
- hadv :: (Num b, Ord k, Sel1 a1 (Map k a), Sel2 a b) => k -> a1 -> b
- kernAdvance :: String -> String -> Kern -> Bool -> Double
- type OutlineMap = Map String (Path R2)
- data Mode
- mWH :: Mode -> Bool
- mW :: Mode -> Bool
- mH :: Mode -> Bool
- data Spacing
- isKern :: Spacing -> Bool
- type FileName = String
- textSVG :: String -> Double -> Path R2
- data TextOpts = TextOpts {}
- ro :: FilePath -> FilePath
- bit :: (FontData, OutlineMap)
- lin :: (FontData, OutlineMap)
- lin2 :: (FontData, OutlineMap)
- textSVG_ :: TextOpts -> Path R2
- bbox_dy :: (Num a1, Sel3 a [a1]) => a -> a1
- bbox_lx :: Sel3 a1 [a] => a1 -> a
- bbox_ly :: Sel3 a1 [a] => a1 -> a
- outlMap :: String -> (FontData, OutlineMap)
- commandsToTrails :: [PathCommand] -> [Segment R2] -> R2 -> R2 -> R2 -> [Path R2]
- commands :: String -> SvgGlyph -> [PathCommand]
Documentation
= (Map String [Int], Map String [Int], Map String [Int], Map String [Int], Vector Double) | u1s, u2s, g1s, g2s, k |
See http://www.w3.org/TR/SVG/fonts.html#KernElements
Some explanation how kerning is computed:
In Linlibertine.svg, there are two groups of chars: i.e.
<hkern g1="f,longs,uni1E1F,f_f" g2="parenright,bracketright,braceright" k="-37" />
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 multiset
,
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
horizontalAdvances :: [String] -> FontData -> Bool -> [Double]Source
horizontal advances of characters inside a string a character is stored with a string (originally because of ligatures)
bit :: (FontData, OutlineMap)Source
lin :: (FontData, OutlineMap)Source
lin2 :: (FontData, OutlineMap)Source
textSVG_ :: TextOpts -> Path R2Source
Main library functions, usage:
{-# LANGUAGE NoMonomorphismRestriction #-} import Diagrams.Prelude import Diagrams.Backend.Cairo.CmdLine import Graphics.SVGFonts.ReadFont main = defaultMain ( (text' "Hello World") <> (rect 8 1) # alignBL ) text' t = stroke (textSVG_ $ TextOpts t lin INSIDE_H KERN 1 1 ) # fc purple # fillRule EvenOdd
outlMap :: String -> (FontData, OutlineMap)Source
Generate Paths of outlines
commandsToTrails :: [PathCommand] -> [Segment R2] -> R2 -> R2 -> R2 -> [Path R2]Source
commands :: String -> SvgGlyph -> [PathCommand]Source