Dump the GASP table

This commit is contained in:
Eugen Wissner 2023-12-06 11:04:08 +01:00
parent b87abcbf2f
commit a841f138fc
2 changed files with 20 additions and 4 deletions

View File

@ -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

View File

@ -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