Dump cmap segment summary
This commit is contained in:
parent
db61d2e558
commit
e5ed4f1b96
@ -41,6 +41,7 @@ import Graphics.Fountainhead.Parser
|
|||||||
, parseTable
|
, parseTable
|
||||||
, cmapTableP
|
, cmapTableP
|
||||||
)
|
)
|
||||||
|
import Data.Foldable (Foldable(..))
|
||||||
|
|
||||||
type ParseErrorOrDump
|
type ParseErrorOrDump
|
||||||
= Either (Megaparsec.ParseErrorBundle ByteString Void) Text.Builder.Builder
|
= Either (Megaparsec.ParseErrorBundle ByteString Void) Text.Builder.Builder
|
||||||
@ -52,6 +53,12 @@ paddedHexadecimal = ("0x" <>)
|
|||||||
. Text.Builder.toLazyText
|
. Text.Builder.toLazyText
|
||||||
. Text.Builder.hexadecimal
|
. Text.Builder.hexadecimal
|
||||||
|
|
||||||
|
halfPaddedHexadecimal :: Integral a => a -> Text.Builder.Builder
|
||||||
|
halfPaddedHexadecimal = Text.Builder.fromLazyText
|
||||||
|
. Text.Lazy.justifyRight 4 '0'
|
||||||
|
. Text.Builder.toLazyText
|
||||||
|
. Text.Builder.hexadecimal
|
||||||
|
|
||||||
justifyNumber :: Integral a => Int64 -> a -> Text.Builder.Builder
|
justifyNumber :: Integral a => Int64 -> a -> Text.Builder.Builder
|
||||||
justifyNumber count = Text.Builder.fromLazyText
|
justifyNumber count = Text.Builder.fromLazyText
|
||||||
. Text.Lazy.justifyRight count ' '
|
. Text.Lazy.justifyRight count ' '
|
||||||
@ -120,23 +127,37 @@ dumpCmap CmapTable{..}
|
|||||||
(CmapFormat0 _) -> "Format 0"
|
(CmapFormat0 _) -> "Format 0"
|
||||||
(CmapFormat2 _) -> "Format 2"
|
(CmapFormat2 _) -> "Format 2"
|
||||||
(CmapFormat4 CmapFormat4Table{..}) ->
|
(CmapFormat4 CmapFormat4Table{..}) ->
|
||||||
"Format 4 - Segment mapping to delta values\n\
|
let segCount = Vector.length startCode
|
||||||
|
in "Format 4 - Segment mapping to delta values\n\
|
||||||
\ Length: 994\n\
|
\ Length: 994\n\
|
||||||
\ Version: 0\n\
|
\ Version: 0\n\
|
||||||
\ segCount: "
|
\ segCount: "
|
||||||
<> Text.Builder.decimal (Vector.length startCode)
|
<> Text.Builder.decimal segCount
|
||||||
<> newlineBuilder <> " searchRange: "
|
<> newlineBuilder <> " searchRange: "
|
||||||
<> Text.Builder.decimal searchRange
|
<> Text.Builder.decimal searchRange
|
||||||
<> newlineBuilder <> " entrySelector: "
|
<> newlineBuilder <> " entrySelector: "
|
||||||
<> Text.Builder.decimal entrySelector
|
<> Text.Builder.decimal entrySelector
|
||||||
<> newlineBuilder <> " rangeShift: "
|
<> newlineBuilder <> " rangeShift: "
|
||||||
<> Text.Builder.decimal (Vector.length startCode * 2 - fromIntegral searchRange)
|
<> Text.Builder.decimal (segCount * 2 - fromIntegral searchRange)
|
||||||
|
<> newlineBuilder
|
||||||
|
<> fold (Vector.izipWith4 (dumpSegment segCount) startCode endCode idDelta idRangeOffset)
|
||||||
(CmapFormat6 _) -> "Format 6"
|
(CmapFormat6 _) -> "Format 6"
|
||||||
(CmapFormat8 _) -> "Format 8"
|
(CmapFormat8 _) -> "Format 8"
|
||||||
(CmapFormat10 _) -> "Format 10"
|
(CmapFormat10 _) -> "Format 10"
|
||||||
(CmapFormat12 _) -> "Format 12"
|
(CmapFormat12 _) -> "Format 12"
|
||||||
(CmapFormat13 _) -> "Format 13"
|
(CmapFormat13 _) -> "Format 13"
|
||||||
(CmapFormat14 _) -> "Format 14"
|
(CmapFormat14 _) -> "Format 14"
|
||||||
|
dumpSegment segCount index startCode' endCode' idDelta' idRangeOffset'
|
||||||
|
= " Seg " <> justifyNumber 5 index
|
||||||
|
<> " : St = " <> halfPaddedHexadecimal startCode'
|
||||||
|
<> ", En = " <> halfPaddedHexadecimal endCode'
|
||||||
|
<> ", D = " <> justifyNumber 6 idDelta'
|
||||||
|
<> ", RO = " <> justifyNumber 6 idRangeOffset'
|
||||||
|
<> ", gId# = " <> dumpGlyphId index segCount idRangeOffset'
|
||||||
|
<> newlineBuilder
|
||||||
|
dumpGlyphId index segCount idRangeOffset'
|
||||||
|
| idRangeOffset' == 0 = "N/A"
|
||||||
|
| otherwise = Text.Builder.decimal $ index - segCount + (fromIntegral idRangeOffset' `div` 2)
|
||||||
|
|
||||||
dumpTables
|
dumpTables
|
||||||
:: Megaparsec.State ByteString Void
|
:: Megaparsec.State ByteString Void
|
||||||
|
Loading…
Reference in New Issue
Block a user