Dump OS/2 microsoft fields

This commit is contained in:
Eugen Wissner 2023-12-03 08:17:05 +01:00
parent 7057ada9aa
commit ea7f729058

View File

@ -68,6 +68,9 @@ import Graphics.Fountainhead.TrueType
, TrueMaxpTable(..) , TrueMaxpTable(..)
, nameStringOffset , nameStringOffset
, Os2BaseFields(..) , Os2BaseFields(..)
, Os2MicrosoftFields(..)
, Os2Version1Fields(..)
, Os2Version4Fields(..)
, Os2Table(..) , Os2Table(..)
, Panose(..) , Panose(..)
) )
@ -250,12 +253,29 @@ dumpOs2 :: Os2Table -> Text.Builder.Builder
dumpOs2 = (dumpCaption "'OS/2' Table - OS/2 and Windows Metrics" <>) . go dumpOs2 = (dumpCaption "'OS/2' Table - OS/2 and Windows Metrics" <>) . go
where where
go = \case go = \case
Os2Version0 baseFields _ -> dumpBaseFields baseFields Os2Version0 baseFields msFields -> dumpBaseFields baseFields
Os2Version1 baseFields _ _ -> dumpBaseFields baseFields <> maybe "" dumpMicrosoftFields msFields
Os2Version2 baseFields _ _ -> dumpBaseFields baseFields Os2Version1 baseFields msFields extraFields -> dumpBaseFields baseFields
Os2Version3 baseFields _ _ -> dumpBaseFields baseFields <> dumpMicrosoftFields msFields <> dumpVersion1Fields extraFields
Os2Version4 baseFields _ _ -> dumpBaseFields baseFields Os2Version2 baseFields msFields extraFields -> dumpBaseFields baseFields
Os2Version5 baseFields _ _ -> dumpBaseFields baseFields <> dumpMicrosoftFields msFields <> dumpVersion4Fields extraFields
Os2Version3 baseFields msFields extraFields -> dumpBaseFields baseFields
<> dumpMicrosoftFields msFields <> dumpVersion4Fields extraFields
Os2Version4 baseFields msFields extraFields -> dumpBaseFields baseFields
<> dumpMicrosoftFields msFields <> dumpVersion4Fields extraFields
Os2Version5 baseFields msFields _ -> dumpBaseFields baseFields
<> dumpMicrosoftFields msFields
dumpVersion1Fields Os2Version1Fields{..}
= " CodePage Range 1( Bits 0 - 31 ): " <> paddedHexadecimal ulCodePageRange1 <> newlineBuilder
<> " CodePage Range 2( Bits 32- 63 ): " <> paddedHexadecimal ulCodePageRange2 <> newlineBuilder
dumpVersion4Fields Os2Version4Fields{..}
= dumpVersion1Fields (Os2Version1Fields ulCodePageRange1 ulCodePageRange2)
dumpMicrosoftFields Os2MicrosoftFields{..}
= " sTypoAscender: " <> Text.Builder.decimal sTypoAscender <> newlineBuilder
<> " sTypoDescender: " <> Text.Builder.decimal sTypoDescender <> newlineBuilder
<> " sTypoLineGap: " <> Text.Builder.decimal sTypoLineGap <> newlineBuilder
<> " usWinAscent: " <> Text.Builder.decimal usWinAscent <> newlineBuilder
<> " usWinDescent: " <> Text.Builder.decimal usWinDescent <> newlineBuilder
dumpBaseFields Os2BaseFields{..} dumpBaseFields Os2BaseFields{..}
= " 'OS/2' version: " <> Text.Builder.decimal version <> newlineBuilder = " 'OS/2' version: " <> Text.Builder.decimal version <> newlineBuilder
<> " xAvgCharWidth: " <> Text.Builder.decimal xAvgCharWidth <> newlineBuilder <> " xAvgCharWidth: " <> Text.Builder.decimal xAvgCharWidth <> newlineBuilder
@ -276,6 +296,15 @@ dumpOs2 = (dumpCaption "'OS/2' Table - OS/2 and Windows Metrics" <>) . go
<> " PANOSE:" <> newlineBuilder <> dumpPanose panose <> " PANOSE:" <> newlineBuilder <> dumpPanose panose
<> fold (Vector.imap dumpUnicodeRange ulUnicodeRange) <> fold (Vector.imap dumpUnicodeRange ulUnicodeRange)
<> " achVendID: '" <> achVendID' achVendID <> "'\n" <> " achVendID: '" <> achVendID' achVendID <> "'\n"
<> " fsSelection: 0x" <> fsSelection' fsSelection <> newlineBuilder
<> " usFirstCharIndex: 0x" <> halfPaddedHexadecimal fsFirstCharIndex <> newlineBuilder
<> " usLastCharIndex: 0x" <> halfPaddedHexadecimal fsLastCharIndex <> newlineBuilder
fsSelection' value =
let description = fold
[ if testBit value 0 then "Italic " else ""
, if testBit value 5 then "Bold " else ""
]
in halfPaddedHexadecimal value <> " '" <> description <> "'"
achVendID' = Text.Builder.fromText . Text.decodeLatin1 . ByteString.pack . fmap fromIntegral . toList achVendID' = Text.Builder.fromText . Text.decodeLatin1 . ByteString.pack . fmap fromIntegral . toList
dumpUnicodeRange index value = dumpUnicodeRange index value =
let bits = index * 32 let bits = index * 32