summaryrefslogtreecommitdiff
path: root/src/Graphics/Fountainhead/Parser.hs
diff options
context:
space:
mode:
authorEugen Wissner <belka@caraus.de>2023-12-05 18:36:14 +0100
committerEugen Wissner <belka@caraus.de>2023-12-05 18:36:14 +0100
commitb87abcbf2f6453419952ce38dbef1e906b185767 (patch)
tree2da36b1ae0007008ea594522f14a403f5a783dcd /src/Graphics/Fountainhead/Parser.hs
parent0cda68e19bfbd2feebaccbaa76bbec7cefce0b78 (diff)
downloadfountainhead-b87abcbf2f6453419952ce38dbef1e906b185767.tar.gz
Parse GASP table
Diffstat (limited to 'src/Graphics/Fountainhead/Parser.hs')
-rw-r--r--src/Graphics/Fountainhead/Parser.hs23
1 files changed, 21 insertions, 2 deletions
diff --git a/src/Graphics/Fountainhead/Parser.hs b/src/Graphics/Fountainhead/Parser.hs
index 6a5433a..51948f7 100644
--- a/src/Graphics/Fountainhead/Parser.hs
+++ b/src/Graphics/Fountainhead/Parser.hs
@@ -18,6 +18,7 @@ module Graphics.Fountainhead.Parser
, fixedP
, fontDirectoryP
, fpgmTableP
+ , gaspTableP
, glyfTableP
, hdmxTableP
, headTableP
@@ -97,6 +98,8 @@ import Graphics.Fountainhead.TrueType
, FontDirectionHint(..)
, FontDirectory(..)
, FontStyle(..)
+ , GASPRange(..)
+ , GASPTable(..)
, GlyfTable(..)
, GlyphArgument(..)
, GlyphCoordinate(..)
@@ -842,8 +845,7 @@ cmapFormat4TableP = do
entrySelector' <- Megaparsec.Binary.word16be
rangeShift' <- Megaparsec.Binary.word16be
endCode' <- vectorNP segCount Megaparsec.Binary.word16be
- rangeShift' <- Megaparsec.Binary.word16be
- -- reservedPad 0.
+ void $ Megaparsec.chunk $ ByteString.pack [0, 0] -- reservedPad 0.
startCode' <- vectorNP segCount Megaparsec.Binary.word16be
idDelta' <- vectorNP segCount Megaparsec.Binary.word16be
idRangeOffset' <- vectorNP segCount Megaparsec.Binary.word16be
@@ -1211,3 +1213,20 @@ bMidlineP
<|> (Megaparsec.single 12 $> LowPointedMidline)
<|> (Megaparsec.single 13 $> LowSerifedMidline)
<?> "bMidline"
+
+-- * Grid-fitting And Scan-conversion Procedure.
+
+gaspTableP :: Parser GASPTable
+gaspTableP = do
+ version' <- Megaparsec.Binary.word16be
+ numberRanges <- fromIntegral <$> Megaparsec.Binary.word16be
+ parsedRanges <- Megaparsec.count numberRanges gaspRangeP
+ Megaparsec.eof
+ pure $ GASPTable
+ { version = version'
+ , gaspRange = parsedRanges
+ }
+ where
+ gaspRangeP = GASPRange
+ <$> Megaparsec.Binary.word16be
+ <*> Megaparsec.Binary.word16be