From ac03d3236deececd13660295d8528e2d0de639ed Mon Sep 17 00:00:00 2001 From: Eugen Wissner Date: Thu, 16 Nov 2023 09:09:59 +0100 Subject: Dump font style --- src/Graphics/Fountainhead/Parser.hs | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'src/Graphics/Fountainhead/Parser.hs') diff --git a/src/Graphics/Fountainhead/Parser.hs b/src/Graphics/Fountainhead/Parser.hs index ea809d2..02d7a29 100644 --- a/src/Graphics/Fountainhead/Parser.hs +++ b/src/Graphics/Fountainhead/Parser.hs @@ -49,18 +49,15 @@ import Data.Int (Int8, Int16) import Data.IntMap (IntMap) import qualified Data.IntMap as IntMap import Data.Functor (($>)) -import Data.List (nub, sort, sortOn, nubBy, sortBy) +import Data.List (sortOn, nubBy, sortBy) import Data.List.NonEmpty (NonEmpty(..)) import qualified Data.List.NonEmpty as NonEmpty -import Data.Maybe (fromMaybe) import Data.Time ( LocalTime(..) - , TimeOfDay(..) , addDays , secondsToDiffTime , timeToTimeOfDay ) -import Data.Time.Calendar.OrdinalDate (fromOrdinalDate) import Data.Vector (Vector) import qualified Data.Vector as Vector import Data.Void (Void) @@ -139,7 +136,7 @@ import Graphics.Fountainhead.TrueType , VariationSelectorMap , unLocaTable ) -import Graphics.Fountainhead.Type (F2Dot14(..), Fixed32(..)) +import Graphics.Fountainhead.Type (F2Dot14(..), Fixed32(..), ttfEpoch) import Text.Megaparsec (()) import qualified Text.Megaparsec as Megaparsec import qualified Text.Megaparsec.Byte.Binary as Megaparsec.Binary @@ -196,8 +193,8 @@ nameTableP = do , variable = parseVariable variable' <$> nameRecord' } where - parseVariable variable' NameRecord{ offset, length } = - ByteString.take length $ ByteString.drop offset variable' + parseVariable variable' NameRecord{ offset, length = length' } = + ByteString.take length' $ ByteString.drop offset variable' nameRecordP :: Parser NameRecord nameRecordP = NameRecord @@ -915,9 +912,8 @@ longDateTimeP = go <$> Megaparsec.Binary.int64be where go totalSeconds = let (totalDays, secondsOfDay) = totalSeconds `divMod` (3600 * 24) - epoch = fromOrdinalDate 1904 1 in LocalTime - { localDay = addDays (fromIntegral totalDays) epoch + { localDay = addDays (fromIntegral totalDays) ttfEpoch , localTimeOfDay = timeToTimeOfDay $ secondsToDiffTime $ fromIntegral secondsOfDay -- cgit v1.2.3