diff options
| author | Eugen Wissner <belka@caraus.de> | 2024-02-04 11:07:15 +0100 |
|---|---|---|
| committer | Eugen Wissner <belka@caraus.de> | 2024-02-04 11:07:15 +0100 |
| commit | 3160ceab080fca8fef0cf2cf196b46284d15c19f (patch) | |
| tree | e9849111325d8431b39618f190a2f0f7a570945f /lib/Graphics/Fountainhead/Metrics.hs | |
| parent | a34b46e1b553623d5dc385fc8e235df808fbadb2 (diff) | |
| download | fountainhead-3160ceab080fca8fef0cf2cf196b46284d15c19f.tar.gz | |
Create a Metrics module
Diffstat (limited to 'lib/Graphics/Fountainhead/Metrics.hs')
| -rw-r--r-- | lib/Graphics/Fountainhead/Metrics.hs | 29 |
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 |
