diff options
| author | Eugen Wissner <belka@caraus.de> | 2023-11-16 09:09:59 +0100 |
|---|---|---|
| committer | Eugen Wissner <belka@caraus.de> | 2023-11-16 09:09:59 +0100 |
| commit | ac03d3236deececd13660295d8528e2d0de639ed (patch) | |
| tree | 2cdc8c45779417294264588b40ea910f9224cb85 /src/Graphics/Fountainhead/Parser.hs | |
| parent | 3414b4cab689cbb8197cb645f5c64acf93aa11d2 (diff) | |
| download | fountainhead-ac03d3236deececd13660295d8528e2d0de639ed.tar.gz | |
Dump font style
Diffstat (limited to 'src/Graphics/Fountainhead/Parser.hs')
| -rw-r--r-- | src/Graphics/Fountainhead/Parser.hs | 14 |
1 files changed, 5 insertions, 9 deletions
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 |
