30 lines
1.0 KiB
Haskell
30 lines
1.0 KiB
Haskell
|
{- This Source Code Form is subject to the terms of the Mozilla Public License,
|
||
|
v. 2.0. If a copy of the MPL was not distributed with this file, You can
|
||
|
obtain one at https://mozilla.org/MPL/2.0/. -}
|
||
|
|
||
|
{-# LANGUAGE OverloadedStrings #-}
|
||
|
{-# LANGUAGE RecordWildCards #-}
|
||
|
|
||
|
module Graphics.Fountainhead.Metrics
|
||
|
( FontMetrics(..)
|
||
|
, afmFontMetrics
|
||
|
) where
|
||
|
|
||
|
import qualified Data.Text.Lazy.Builder as Text.Builder
|
||
|
import Data.Version (Version(..), showVersion)
|
||
|
import Graphics.Fountainhead.Type (newlineBuilder)
|
||
|
|
||
|
newtype FontMetrics = FontMetrics
|
||
|
{ version :: Version
|
||
|
} deriving (Eq, Show)
|
||
|
|
||
|
afmKeyString :: Text.Builder.Builder -> String -> Text.Builder.Builder
|
||
|
afmKeyString key value = key <> Text.Builder.singleton '\t'
|
||
|
<> Text.Builder.fromString value <> newlineBuilder
|
||
|
|
||
|
afmFontMetrics :: FontMetrics -> Text.Builder.Builder
|
||
|
afmFontMetrics FontMetrics{..}
|
||
|
= afmKeyString "StartFontMetrics" (showVersion version)
|
||
|
<> afmKeyString "Comment" "Generated by Fountainhead"
|
||
|
<> "EndFontMetrics" <> newlineBuilder
|