summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugen Wissner <belka@caraus.de>2023-12-06 11:04:08 +0100
committerEugen Wissner <belka@caraus.de>2023-12-06 11:04:08 +0100
commita841f138fc9055f4bc32db292a675f93f081b4e7 (patch)
tree6ae8000137a0a76d5537a8be7d20f1a5cc8b2a3e
parentb87abcbf2f6453419952ce38dbef1e906b185767 (diff)
downloadfountainhead-a841f138fc9055f4bc32db292a675f93f081b4e7.tar.gz
Dump the GASP table
-rw-r--r--src/Graphics/Fountainhead/Dumper.hs16
-rw-r--r--src/Graphics/Fountainhead/Parser.hs8
2 files changed, 20 insertions, 4 deletions
diff --git a/src/Graphics/Fountainhead/Dumper.hs b/src/Graphics/Fountainhead/Dumper.hs
index 3bbbf3f..46655cb 100644
--- a/src/Graphics/Fountainhead/Dumper.hs
+++ b/src/Graphics/Fountainhead/Dumper.hs
@@ -45,6 +45,8 @@ import Graphics.Fountainhead.TrueType
( CmapTable(..)
, FontDirectory(..)
, FontDirectionHint(..)
+ , GASPRange(..)
+ , GASPTable(..)
, HeadTable(..)
, HheaTable(..)
, HmtxTable(..)
@@ -84,6 +86,7 @@ import Graphics.Fountainhead.Parser
, headTableP
, hheaTableP
, hmtxTableP
+ , gaspTableP
, locaTableP
, maxpTableP
, nameTableP
@@ -617,6 +620,18 @@ dumpMaxp (OpenMaxp OpenMaxpTable{..})
<> " 'maxp' version: " <> dumpFixed32 version <> newlineBuilder <> newlineBuilder
<> " numGlyphs: " <> Text.Builder.decimal numGlyphs <> newlineBuilder
+dumpGASP :: GASPTable -> Text.Builder.Builder
+dumpGASP GASPTable{..} = dumpCaption "'gasp' Table - Grid-fitting And Scan-conversion Procedure"
+ <> "'gasp' version: " <> Text.Builder.decimal version <> newlineBuilder
+ <> "numRanges: " <> Text.Builder.decimal (Prelude.length gaspRange) <> newlineBuilder
+ <> foldMap dumpGASPRange (zip [0..] gaspRange)
+ where
+ dumpGASPRange :: (Int, GASPRange) -> Text.Builder.Builder
+ dumpGASPRange (index', GASPRange{..}) = newlineBuilder
+ <> " gasp Range " <> Text.Builder.decimal index' <> newlineBuilder
+ <> " rangeMaxPPEM: " <> Text.Builder.decimal rangeMaxPPEM <> newlineBuilder
+ <> " rangeGaspBehavior: 0x" <> halfPaddedHexadecimal rangeGaspBehavior <> newlineBuilder
+
dumpTables
:: Megaparsec.State ByteString Void
-> FontDirectory
@@ -655,6 +670,7 @@ dumpTables processedState directory@FontDirectory{..}
"post" -> Just $ dumpPost <$> parseTable tableEntry postTableP processedState
"OS/2" -> Just $ dumpOs2 <$> parseTable tableEntry os2TableP processedState
"cvt " -> Just $ dumpCVTable <$> parseTable tableEntry cvTableP processedState
+ "gasp" -> Just $ dumpGASP <$> parseTable tableEntry gaspTableP processedState
_ -> Nothing
dumpTrueType :: ByteString -> FilePath -> Either DumpError Text.Builder.Builder
diff --git a/src/Graphics/Fountainhead/Parser.hs b/src/Graphics/Fountainhead/Parser.hs
index 51948f7..590f95f 100644
--- a/src/Graphics/Fountainhead/Parser.hs
+++ b/src/Graphics/Fountainhead/Parser.hs
@@ -775,7 +775,7 @@ cmapFormat13TableP = cmapFormat12TableP
cmapFormat12TableP :: Parser CmapFormat12Table
cmapFormat12TableP = do
- Megaparsec.takeP Nothing 6 -- Reserved and length.
+ void $ Megaparsec.takeP Nothing 6 -- Reserved and length.
language' <- Megaparsec.Binary.word32be
nGroups <- fromIntegral <$> Megaparsec.Binary.word32be
groups' <- vectorNP nGroups cmapGroupP
@@ -787,7 +787,7 @@ cmapFormat12TableP = do
cmapFormat10TableP :: Parser CmapFormat10Table
cmapFormat10TableP = do
- Megaparsec.takeP Nothing 2 -- Reserved.
+ void $ Megaparsec.takeP Nothing 2 -- Reserved.
length' <- fromIntegral <$> Megaparsec.Binary.word32be
language' <- Megaparsec.Binary.word32be
startCharCode' <- Megaparsec.Binary.word32be
@@ -804,7 +804,7 @@ cmapFormat10TableP = do
cmapFormat8TableP :: Parser CmapFormat8Table
cmapFormat8TableP = do
- Megaparsec.takeP Nothing 6 -- Reserved and length.
+ void $ Megaparsec.takeP Nothing 6 -- Reserved and length.
language' <- Megaparsec.Binary.word32be
is32' <- Megaparsec.takeP Nothing 65536
nGroups <- fromIntegral <$> Megaparsec.Binary.word32be
@@ -824,7 +824,7 @@ cmapGroupP = CmapGroup
cmapFormat6TableP :: Parser CmapFormat6Table
cmapFormat6TableP = do
- Megaparsec.Binary.word16be -- Length.
+ void Megaparsec.Binary.word16be -- Length.
language' <- Megaparsec.Binary.word16be
firstCode' <- Megaparsec.Binary.word16be
entryCount' <- fromIntegral <$> Megaparsec.Binary.word16be