Dump OS/2 panose fields

This commit is contained in:
Eugen Wissner 2023-12-02 15:14:58 +01:00
parent 7eacf0a2c4
commit 7057ada9aa
2 changed files with 171 additions and 14 deletions

View File

@ -272,19 +272,41 @@ dumpOs2 = (dumpCaption "'OS/2' Table - OS/2 and Windows Metrics" <>) . go
<> " ySuperscriptYOffset: " <> Text.Builder.decimal ySuperscriptYOffset <> newlineBuilder <> " ySuperscriptYOffset: " <> Text.Builder.decimal ySuperscriptYOffset <> newlineBuilder
<> " yStrikeoutSize: " <> Text.Builder.decimal yStrikeoutSize <> newlineBuilder <> " yStrikeoutSize: " <> Text.Builder.decimal yStrikeoutSize <> newlineBuilder
<> " yStrikeoutPosition: " <> Text.Builder.decimal yStrikeoutPosition <> newlineBuilder <> " yStrikeoutPosition: " <> Text.Builder.decimal yStrikeoutPosition <> newlineBuilder
<> " sFamilyClass:" <> familyClass sFamilyClass <> " sFamilyClass:" <> familyClass sFamilyClass <> newlineBuilder
<> " PANOSE:" <> newlineBuilder <> dumpPanose panose <> " PANOSE:" <> newlineBuilder <> dumpPanose panose
<> fold (Vector.imap dumpUnicodeRange ulUnicodeRange)
<> " achVendID: '" <> achVendID' achVendID <> "'\n"
achVendID' = Text.Builder.fromText . Text.decodeLatin1 . ByteString.pack . fmap fromIntegral . toList
dumpUnicodeRange index value =
let bits = index * 32
parens = "( Bits " <> Text.Builder.decimal bits <> " - "
<> Text.Builder.decimal (bits + 31) <> " ):"
in " Unicode Range: " <> Text.Builder.decimal (index + 1)
<> Text.Builder.fromLazyText (Text.Lazy.justifyLeft 25 ' ' (Text.Builder.toLazyText parens))
<> paddedHexadecimal value
<> newlineBuilder
dumpPanose Panose{..} dumpPanose Panose{..}
= " Family Kind: 0 'Any'" = " Family Kind: " <> dumpPanoseField bFamilyType
<> " Serif Style: 0 'Any'" <> " Serif Style: " <> dumpPanoseField bSerifStyle
<> " Weight: 0 'Any'" <> " Weight: " <> dumpPanoseField bWeight
<> " Proportion: 0 'Any'" <> " Proportion: " <> dumpPanoseField bProportion
<> " Contrast: 0 'Any'" <> " Contrast: " <> dumpPanoseField bContrast
<> " Stroke: 0 'Any'" <> " Stroke: " <> dumpPanoseField bStrokeVariation
<> " Arm Style: 0 'Any'" <> " Arm Style: " <> dumpPanoseField bArmStyle
<> " Lettreform: 0 'Any'" <> " Lettreform: " <> dumpPanoseField bLetterform
<> " Midline: 0 'Any'" <> " Midline: " <> dumpPanoseField bMidline
<> " X-height: 0 'Any'" <> " X-height: " <> dumpPanoseField bXHeight
dumpPanoseField field' =
let numericField = Text.Builder.fromLazyText
$ Text.Lazy.justifyLeft 8 ' '
$ Text.Builder.toLazyText
$ Text.Builder.decimal
$ fromEnum field'
in numericField
<> Text.Builder.singleton '\''
<> Text.Builder.fromString (show field')
<> Text.Builder.singleton '\''
<> newlineBuilder
familyClass value = familyClass value =
" " <> Text.Builder.decimal (value .>>. 8) <> " subclass = " <> Text.Builder.decimal (value .&. 0x00ff) " " <> Text.Builder.decimal (value .>>. 8) <> " subclass = " <> Text.Builder.decimal (value .&. 0x00ff)
weightClass classValue weightClass classValue

View File

@ -1007,7 +1007,62 @@ data BLetterform
| ObliqueRoundedLetterform | ObliqueRoundedLetterform
| ObliqueOffCenterLetterform | ObliqueOffCenterLetterform
| ObliqueSquareLetterform | ObliqueSquareLetterform
deriving (Eq, Show) deriving Eq
instance Show BLetterform
where
show AnyLetterform = "Any"
show NoFitLetterform = "No Fit"
show NormalContactLetterform = "Normal/Contact"
show NormalWeightedLetterform = "Normal/Weighted"
show NormalBoxedLetterform = "Normal/Boxed"
show NormalFlattenedLetterform = "Normal/Flattened"
show NormalRoundedLetterform = "Normal/Rounded"
show NormalOffCenterLetterform = "Normal/Off Center"
show NormalSquareLetterform = "Normal/Square"
show ObliqueContactLetterform = "Oblique/Contact"
show ObliqueWeightedLetterform = "Oblique/Weighted"
show ObliqueBoxedLetterform = "Oblique/Boxed"
show ObliqueFlattenedLetterform = "Oblique/Flattened"
show ObliqueRoundedLetterform = "Oblique/Rounded"
show ObliqueOffCenterLetterform = "Oblique/Off Center"
show ObliqueSquareLetterform = "Oblique/Square"
instance Enum BLetterform
where
fromEnum AnyLetterform = 0
fromEnum NoFitLetterform = 1
fromEnum NormalContactLetterform = 2
fromEnum NormalWeightedLetterform = 3
fromEnum NormalBoxedLetterform = 4
fromEnum NormalFlattenedLetterform = 5
fromEnum NormalRoundedLetterform = 6
fromEnum NormalOffCenterLetterform = 7
fromEnum NormalSquareLetterform = 8
fromEnum ObliqueContactLetterform = 9
fromEnum ObliqueWeightedLetterform = 10
fromEnum ObliqueBoxedLetterform = 11
fromEnum ObliqueFlattenedLetterform = 12
fromEnum ObliqueRoundedLetterform = 13
fromEnum ObliqueOffCenterLetterform = 14
fromEnum ObliqueSquareLetterform = 15
toEnum 0 = AnyLetterform
toEnum 1 = NoFitLetterform
toEnum 2 = NormalContactLetterform
toEnum 3 = NormalWeightedLetterform
toEnum 4 = NormalBoxedLetterform
toEnum 5 = NormalFlattenedLetterform
toEnum 6 = NormalRoundedLetterform
toEnum 7 = NormalOffCenterLetterform
toEnum 8 = NormalSquareLetterform
toEnum 9 = ObliqueContactLetterform
toEnum 10 = ObliqueWeightedLetterform
toEnum 11 = ObliqueBoxedLetterform
toEnum 12 = ObliqueFlattenedLetterform
toEnum 13 = ObliqueRoundedLetterform
toEnum 14 = ObliqueOffCenterLetterform
toEnum 15 = ObliqueSquareLetterform
toEnum _ = error "Unknown letterform"
data BMidline data BMidline
= AnyMidline = AnyMidline
@ -1024,7 +1079,56 @@ data BMidline
| LowTrimmedMidline | LowTrimmedMidline
| LowPointedMidline | LowPointedMidline
| LowSerifedMidline | LowSerifedMidline
deriving (Eq, Show) deriving Eq
instance Show BMidline
where
show AnyMidline = "Any"
show NoFitMidline = "No Fit"
show StandardTrimmedMidline = "Standard/Trimmed"
show StandardPointedMidline = "Standard/Pointed"
show StandardSerifedMidline = "Standard/Serifed"
show HighTrimmedMidline = "High/Trimmed"
show HighPointedMidline = "High/Pointed"
show HighSerifedMidline = "High/Serifed"
show ConstantTrimmedMidline = "Constant/Trimmed"
show ConstantPointedMidline = "Constant/Pointed"
show ConstantSerifedMidline = "Constant/Serifed"
show LowTrimmedMidline = "Low/Trimmed"
show LowPointedMidline = "Low/Pointed"
show LowSerifedMidline = "Low/Serifed"
instance Enum BMidline
where
fromEnum AnyMidline = 0
fromEnum NoFitMidline = 1
fromEnum StandardTrimmedMidline = 2
fromEnum StandardPointedMidline = 3
fromEnum StandardSerifedMidline = 4
fromEnum HighTrimmedMidline = 5
fromEnum HighPointedMidline = 6
fromEnum HighSerifedMidline = 7
fromEnum ConstantTrimmedMidline = 8
fromEnum ConstantPointedMidline = 9
fromEnum ConstantSerifedMidline = 10
fromEnum LowTrimmedMidline = 11
fromEnum LowPointedMidline = 12
fromEnum LowSerifedMidline = 13
toEnum 0 = AnyMidline
toEnum 1 = NoFitMidline
toEnum 2 = StandardTrimmedMidline
toEnum 3 = StandardPointedMidline
toEnum 4 = StandardSerifedMidline
toEnum 5 = HighTrimmedMidline
toEnum 6 = HighPointedMidline
toEnum 7 = HighSerifedMidline
toEnum 8 = ConstantTrimmedMidline
toEnum 9 = ConstantPointedMidline
toEnum 10 = ConstantSerifedMidline
toEnum 11 = LowTrimmedMidline
toEnum 12 = LowPointedMidline
toEnum 13 = LowSerifedMidline
toEnum _ = error "Unknown midline"
data BXHeight data BXHeight
= AnyXHeight = AnyXHeight
@ -1035,7 +1139,38 @@ data BXHeight
| DuckingSmallXHeight | DuckingSmallXHeight
| DuckingStandardXHeight | DuckingStandardXHeight
| DuckingLargeXHeight | DuckingLargeXHeight
deriving (Eq, Show) deriving Eq
instance Show BXHeight
where
show AnyXHeight = "Any"
show NoFitXHeight = "No Fit"
show ConstantSmallXHeight = "Constant/Small"
show ConstantStandardXHeight = "Constant/Standard"
show ConstantLargeXHeight = "Constant/Large"
show DuckingSmallXHeight = "Ducking/Small"
show DuckingStandardXHeight = "Ducking/Standard"
show DuckingLargeXHeight = "Ducking/Large"
instance Enum BXHeight
where
fromEnum AnyXHeight = 0
fromEnum NoFitXHeight = 1
fromEnum ConstantSmallXHeight = 2
fromEnum ConstantStandardXHeight = 3
fromEnum ConstantLargeXHeight = 4
fromEnum DuckingSmallXHeight = 5
fromEnum DuckingStandardXHeight = 6
fromEnum DuckingLargeXHeight = 7
toEnum 0 = AnyXHeight
toEnum 1 = NoFitXHeight
toEnum 2 = ConstantSmallXHeight
toEnum 3 = ConstantStandardXHeight
toEnum 4 = ConstantLargeXHeight
toEnum 5 = DuckingSmallXHeight
toEnum 6 = DuckingStandardXHeight
toEnum 7 = DuckingLargeXHeight
toEnum _ = error "Unknown X height"
-- * Kern table -- * Kern table