summaryrefslogtreecommitdiff
path: root/lib/Graphics/Fountainhead/Metrics.hs
diff options
context:
space:
mode:
authorEugen Wissner <belka@caraus.de>2024-02-04 11:07:15 +0100
committerEugen Wissner <belka@caraus.de>2024-02-04 11:07:15 +0100
commit3160ceab080fca8fef0cf2cf196b46284d15c19f (patch)
treee9849111325d8431b39618f190a2f0f7a570945f /lib/Graphics/Fountainhead/Metrics.hs
parenta34b46e1b553623d5dc385fc8e235df808fbadb2 (diff)
downloadfountainhead-3160ceab080fca8fef0cf2cf196b46284d15c19f.tar.gz
Create a Metrics module
Diffstat (limited to 'lib/Graphics/Fountainhead/Metrics.hs')
-rw-r--r--lib/Graphics/Fountainhead/Metrics.hs29
1 files changed, 29 insertions, 0 deletions
diff --git a/lib/Graphics/Fountainhead/Metrics.hs b/lib/Graphics/Fountainhead/Metrics.hs
new file mode 100644
index 0000000..bb50b93
--- /dev/null
+++ b/lib/Graphics/Fountainhead/Metrics.hs
@@ -0,0 +1,29 @@
+{- 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