module Wumpus.Basic.System.FontLoader.Afm
(
loadAfmMetrics
) where
import Wumpus.Basic.Kernel
import Wumpus.Basic.System.FontLoader.Base.AfmV4Dot1Parser
import Wumpus.Basic.System.FontLoader.Base.Datatypes
import Wumpus.Basic.System.FontLoader.Base.FontLoadMonad
import Wumpus.Core
import Control.Monad
import Data.Monoid
loadAfmMetrics :: FilePath -> [FontName] -> IO (GlyphMetrics, [String])
loadAfmMetrics font_dir_path ns =
liftM post $ runFontLoadIO $ sequenceAll $ map mkFun ns
where
mkFun = afmLoadFontCalcs font_dir_path
post (Left err,ss) = (mempty, ss ++ [err])
post (Right xs,ss) = (foldr insertFont mempty xs, ss)
afmLoadFontCalcs :: FilePath -> FontName -> FontLoadIO FontMetricsOps
afmLoadFontCalcs font_dir_path name = do
logLoadMsg $ "Loading " ++ name
path <- checkFontPath font_dir_path (name ++ ".afm")
ans <- runParserFLIO path afmV4Dot1Parser
props <- buildAfmFontProps afm_mono_defaults_4_1 ans
return $ FontMetricsOps name (buildMetricsOps afmUnitScale props)
afm_mono_defaults_4_1 :: MonospaceDefaults AfmUnit
afm_mono_defaults_4_1 =
MonospaceDefaults { default_letter_bbox = bbox
, default_cap_height = 562
, default_descender = (157)
, default_char_width = V2 600 0
}
where
bbox = BBox (P2 (23) (250)) (P2 715 805)