summaryrefslogtreecommitdiff
path: root/src/Graphics/Fountainhead/Type.hs
diff options
context:
space:
mode:
authorEugen Wissner <belka@caraus.de>2024-02-02 01:44:49 +0100
committerEugen Wissner <belka@caraus.de>2024-02-02 01:44:49 +0100
commit34d3ece99e438e5e81f4df6ca7a36de307e41b3e (patch)
tree27bbf00b10d8cc9fb43cf7462e46c4482505ee89 /src/Graphics/Fountainhead/Type.hs
parent1bcff4c5191cc6c016b8dce77e27ffa8ad46f40c (diff)
downloadfountainhead-34d3ece99e438e5e81f4df6ca7a36de307e41b3e.tar.gz
Dump compound glyph info
Diffstat (limited to 'src/Graphics/Fountainhead/Type.hs')
-rw-r--r--src/Graphics/Fountainhead/Type.hs8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/Graphics/Fountainhead/Type.hs b/src/Graphics/Fountainhead/Type.hs
index 07031e4..e809d9c 100644
--- a/src/Graphics/Fountainhead/Type.hs
+++ b/src/Graphics/Fountainhead/Type.hs
@@ -8,10 +8,12 @@ module Graphics.Fountainhead.Type
, Fixed32(..)
, FWord
, UFWord
+ , fixed2Double
, succIntegral
, ttfEpoch
) where
+import Data.Bits ((.>>.), (.&.))
import Data.Int (Int16)
import Data.Word (Word16, Word32)
import Data.Time (Day(..))
@@ -31,3 +33,9 @@ ttfEpoch = fromOrdinalDate 1904 1
succIntegral :: Integral a => a -> Int
succIntegral = succ . fromIntegral
+
+fixed2Double :: F2Dot14 -> Double
+fixed2Double (F2Dot14 fixed) =
+ let mantissa = realToFrac (fixed .>>. 14)
+ fraction = realToFrac (fixed .&. 0x3fff) / 16384.0
+ in mantissa + fraction