module Wumpus.Basic.System.FontLoader.AfmV4Dot1Parser
(
afmV4Dot1Parser
) where
import Wumpus.Basic.System.FontLoader.AfmParserBase
import Wumpus.Basic.System.FontLoader.Datatypes
import Wumpus.Basic.Utils.ParserCombinators
import Wumpus.Core
import Control.Applicative
afmV4Dot1Parser :: CharParser AfmFile
afmV4Dot1Parser = afmFileParser charMetricsV4Dot1
charMetricsV4Dot1 :: CharParser AfmGlyphMetrics
charMetricsV4Dot1 = AfmGlyphMetrics <$>
characterCode
<*> 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)
characterCode :: CharParser Int
characterCode = metric "CH" (1) hexInt <|> metric "C" (1) cint