module Wumpus.Basic.System.FontLoader.AfmV2Parser
(
afmV2Parser
) where
import Wumpus.Basic.System.FontLoader.AfmParserBase
import Wumpus.Basic.System.FontLoader.Datatypes
import Wumpus.Basic.Utils.ParserCombinators
import Wumpus.Core
import Control.Applicative
afmV2Parser :: CharParser AfmFile
afmV2Parser = afmFileParser charMetricsV2
charMetricsV2 :: CharParser AfmGlyphMetrics
charMetricsV2 = AfmGlyphMetrics <$>
metric "C" (1) cint
<*> widthVector
<*> metric "N" "" name1
<* charBBox
<* many (symbol "L" *> ligature_body <* semi)
<* newlineOrEOF
where
ligature_body = ((,) <$> name <*> name)
widthVector :: CharParser (Vec2 AfmUnit)
widthVector = (symbol "WX" *> ((\w -> vec w 0) <$> number) <* semi)
<|> (symbol "W" *> (vec <$> number <*> number) <* semi)