Dump maxp table
This commit is contained in:
parent
cda2a2a446
commit
af16ee7b8e
@ -16,6 +16,7 @@ module Graphics.Fountainhead.Dumper
|
|||||||
, dumpHmtx
|
, dumpHmtx
|
||||||
, dumpHhea
|
, dumpHhea
|
||||||
, dumpLoca
|
, dumpLoca
|
||||||
|
, dumpMaxp
|
||||||
, dumpTrueType
|
, dumpTrueType
|
||||||
, dumpOffsetTable
|
, dumpOffsetTable
|
||||||
) where
|
) where
|
||||||
@ -49,6 +50,9 @@ import Graphics.Fountainhead.TrueType
|
|||||||
, LongHorMetric(..)
|
, LongHorMetric(..)
|
||||||
, LocaTable(..)
|
, LocaTable(..)
|
||||||
, IndexToLocFormat(..)
|
, IndexToLocFormat(..)
|
||||||
|
, OpenMaxpTable(..)
|
||||||
|
, MaxpTable(..)
|
||||||
|
, TrueMaxpTable(..)
|
||||||
)
|
)
|
||||||
import qualified Text.Megaparsec as Megaparsec
|
import qualified Text.Megaparsec as Megaparsec
|
||||||
import Graphics.Fountainhead.Parser
|
import Graphics.Fountainhead.Parser
|
||||||
@ -59,6 +63,7 @@ import Graphics.Fountainhead.Parser
|
|||||||
, hheaTableP
|
, hheaTableP
|
||||||
, hmtxTableP
|
, hmtxTableP
|
||||||
, locaTableP
|
, locaTableP
|
||||||
|
, maxpTableP
|
||||||
)
|
)
|
||||||
import Graphics.Fountainhead.Type (Fixed32(..), ttfEpoch)
|
import Graphics.Fountainhead.Type (Fixed32(..), ttfEpoch)
|
||||||
import Data.Foldable (Foldable(..), find)
|
import Data.Foldable (Foldable(..), find)
|
||||||
@ -330,13 +335,36 @@ dumpLoca table =
|
|||||||
case Vector.unsnoc elements of
|
case Vector.unsnoc elements of
|
||||||
Just (init', last')
|
Just (init', last')
|
||||||
-> foldMap dumpLocaLine (Vector.indexed init')
|
-> foldMap dumpLocaLine (Vector.indexed init')
|
||||||
<> " Ended at " <> paddedHexadecimal last'
|
<> " Ended at " <> paddedHexadecimal last' <> newlineBuilder
|
||||||
Nothing -> mempty
|
Nothing -> mempty
|
||||||
dumpLocaLine :: Integral a => (Int, a) -> Text.Builder.Builder
|
dumpLocaLine :: Integral a => (Int, a) -> Text.Builder.Builder
|
||||||
dumpLocaLine (index, element)
|
dumpLocaLine (index, element)
|
||||||
= " Idx " <> justifyNumber 6 index
|
= " Idx " <> justifyNumber 6 index
|
||||||
<> " -> GlyphOffset " <> paddedHexadecimal element <> newlineBuilder
|
<> " -> GlyphOffset " <> paddedHexadecimal element <> newlineBuilder
|
||||||
|
|
||||||
|
dumpMaxp :: MaxpTable -> Text.Builder.Builder
|
||||||
|
dumpMaxp (TrueMaxp TrueMaxpTable{..})
|
||||||
|
= dumpCaption "'maxp' Table - Maximum Profile"
|
||||||
|
<> " 'maxp' version: " <> dumpFixed32 version <> newlineBuilder
|
||||||
|
<> " numGlyphs: " <> Text.Builder.decimal numGlyphs <> newlineBuilder
|
||||||
|
<> " maxPoints: " <> Text.Builder.decimal maxPoints <> newlineBuilder
|
||||||
|
<> " maxContours: " <> Text.Builder.decimal maxContours <> newlineBuilder
|
||||||
|
<> " maxCompositePoints: " <> Text.Builder.decimal maxComponentPoints <> newlineBuilder
|
||||||
|
<> " maxCompositeContours: " <> Text.Builder.decimal maxComponentContours <> newlineBuilder
|
||||||
|
<> " maxZones: " <> Text.Builder.decimal maxZones <> newlineBuilder
|
||||||
|
<> " maxTwilightPoints: " <> Text.Builder.decimal maxTwilightPoints <> newlineBuilder
|
||||||
|
<> " maxStorage: " <> Text.Builder.decimal maxStorage <> newlineBuilder
|
||||||
|
<> " maxFunctionDefs: " <> Text.Builder.decimal maxFunctionDefs <> newlineBuilder
|
||||||
|
<> " maxInstructionDefs: " <> Text.Builder.decimal maxInstructionDefs <> newlineBuilder
|
||||||
|
<> " maxStackElements: " <> Text.Builder.decimal maxStackElements <> newlineBuilder
|
||||||
|
<> " maxSizeOfInstructions: " <> Text.Builder.decimal maxSizeOfInstructions <> newlineBuilder
|
||||||
|
<> " maxComponentElements: " <> Text.Builder.decimal maxComponentElements <> newlineBuilder
|
||||||
|
<> " maxCompoenetDepth: " <> Text.Builder.decimal maxComponentDepth <> newlineBuilder
|
||||||
|
dumpMaxp (OpenMaxp OpenMaxpTable{..})
|
||||||
|
= dumpCaption "'maxp' Table - Maximum Profile"
|
||||||
|
<> " 'maxp' version: " <> dumpFixed32 version <> newlineBuilder <> newlineBuilder
|
||||||
|
<> " numGlyphs: " <> Text.Builder.decimal numGlyphs <> newlineBuilder
|
||||||
|
|
||||||
dumpTables
|
dumpTables
|
||||||
:: Megaparsec.State ByteString Void
|
:: Megaparsec.State ByteString Void
|
||||||
-> FontDirectory
|
-> FontDirectory
|
||||||
@ -370,6 +398,7 @@ dumpTables processedState directory@FontDirectory{..}
|
|||||||
<$> parseTable tableEntry (hmtxTableP $ getField @"numOfLongHorMetrics" hheaTable) processedState
|
<$> parseTable tableEntry (hmtxTableP $ getField @"numOfLongHorMetrics" hheaTable) processedState
|
||||||
"loca" -> Just $ dumpLoca
|
"loca" -> Just $ dumpLoca
|
||||||
<$> parseTable tableEntry (locaTableP $ getField @"indexToLocFormat" headTable) processedState
|
<$> parseTable tableEntry (locaTableP $ getField @"indexToLocFormat" headTable) processedState
|
||||||
|
"maxp" -> Just $ dumpMaxp <$> parseTable tableEntry maxpTableP processedState
|
||||||
_ -> Nothing
|
_ -> Nothing
|
||||||
|
|
||||||
dumpTrueType :: ByteString -> FilePath -> Either DumpError Text.Builder.Builder
|
dumpTrueType :: ByteString -> FilePath -> Either DumpError Text.Builder.Builder
|
||||||
|
Loading…
Reference in New Issue
Block a user