diff options
| author | Eugen Wissner <belka@caraus.de> | 2023-11-20 09:33:04 +0100 |
|---|---|---|
| committer | Eugen Wissner <belka@caraus.de> | 2023-11-20 09:33:04 +0100 |
| commit | af16ee7b8ed205f95c271c3a9a9840d1e0e62c85 (patch) | |
| tree | 1c09e0dd1624b419b37ae2b46544cda24e7ac470 /src/Graphics/Fountainhead/Dumper.hs | |
| parent | cda2a2a446f16f1238ed5e145b3ad2f8aaaba88e (diff) | |
| download | fountainhead-af16ee7b8ed205f95c271c3a9a9840d1e0e62c85.tar.gz | |
Dump maxp table
Diffstat (limited to 'src/Graphics/Fountainhead/Dumper.hs')
| -rw-r--r-- | src/Graphics/Fountainhead/Dumper.hs | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/src/Graphics/Fountainhead/Dumper.hs b/src/Graphics/Fountainhead/Dumper.hs index 647f159..cea7c9a 100644 --- a/src/Graphics/Fountainhead/Dumper.hs +++ b/src/Graphics/Fountainhead/Dumper.hs @@ -16,6 +16,7 @@ module Graphics.Fountainhead.Dumper , dumpHmtx , dumpHhea , dumpLoca + , dumpMaxp , dumpTrueType , dumpOffsetTable ) where @@ -49,6 +50,9 @@ import Graphics.Fountainhead.TrueType , LongHorMetric(..) , LocaTable(..) , IndexToLocFormat(..) + , OpenMaxpTable(..) + , MaxpTable(..) + , TrueMaxpTable(..) ) import qualified Text.Megaparsec as Megaparsec import Graphics.Fountainhead.Parser @@ -59,6 +63,7 @@ import Graphics.Fountainhead.Parser , hheaTableP , hmtxTableP , locaTableP + , maxpTableP ) import Graphics.Fountainhead.Type (Fixed32(..), ttfEpoch) import Data.Foldable (Foldable(..), find) @@ -330,13 +335,36 @@ dumpLoca table = case Vector.unsnoc elements of Just (init', last') -> foldMap dumpLocaLine (Vector.indexed init') - <> " Ended at " <> paddedHexadecimal last' + <> " Ended at " <> paddedHexadecimal last' <> newlineBuilder Nothing -> mempty dumpLocaLine :: Integral a => (Int, a) -> Text.Builder.Builder dumpLocaLine (index, element) = " Idx " <> justifyNumber 6 index <> " -> 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 :: Megaparsec.State ByteString Void -> FontDirectory @@ -370,6 +398,7 @@ dumpTables processedState directory@FontDirectory{..} <$> parseTable tableEntry (hmtxTableP $ getField @"numOfLongHorMetrics" hheaTable) processedState "loca" -> Just $ dumpLoca <$> parseTable tableEntry (locaTableP $ getField @"indexToLocFormat" headTable) processedState + "maxp" -> Just $ dumpMaxp <$> parseTable tableEntry maxpTableP processedState _ -> Nothing dumpTrueType :: ByteString -> FilePath -> Either DumpError Text.Builder.Builder |
