Rename StrokeVariatoon to StrokeVariation

This commit is contained in:
Eugen Wissner 2023-12-01 14:20:25 +01:00
parent b0950899cc
commit 7eacf0a2c4
3 changed files with 314 additions and 27 deletions

View File

@ -69,6 +69,7 @@ import Graphics.Fountainhead.TrueType
, nameStringOffset
, Os2BaseFields(..)
, Os2Table(..)
, Panose(..)
)
import qualified Text.Megaparsec as Megaparsec
import Graphics.Fountainhead.Parser
@ -272,6 +273,18 @@ dumpOs2 = (dumpCaption "'OS/2' Table - OS/2 and Windows Metrics" <>) . go
<> " yStrikeoutSize: " <> Text.Builder.decimal yStrikeoutSize <> newlineBuilder
<> " yStrikeoutPosition: " <> Text.Builder.decimal yStrikeoutPosition <> newlineBuilder
<> " sFamilyClass:" <> familyClass sFamilyClass
<> " PANOSE:" <> newlineBuilder <> dumpPanose panose
dumpPanose Panose{..}
= " Family Kind: 0 'Any'"
<> " Serif Style: 0 'Any'"
<> " Weight: 0 'Any'"
<> " Proportion: 0 'Any'"
<> " Contrast: 0 'Any'"
<> " Stroke: 0 'Any'"
<> " Arm Style: 0 'Any'"
<> " Lettreform: 0 'Any'"
<> " Midline: 0 'Any'"
<> " X-height: 0 'Any'"
familyClass value =
" " <> Text.Builder.decimal (value .>>. 8) <> " subclass = " <> Text.Builder.decimal (value .&. 0x00ff)
weightClass classValue

View File

@ -720,7 +720,7 @@ cmapFormat14TableP = do
currentOffset <- Megaparsec.getOffset
let emptyBytes = tableOffset + fromIntegral relativeOffset - currentOffset
relativeOffset' = fromIntegral relativeOffset
Megaparsec.takeP Nothing emptyBytes
void $ Megaparsec.takeP Nothing emptyBytes
entryCount <- fromIntegral <$> Megaparsec.Binary.word32be
valueRanges <- vectorNP entryCount unicodeValueRangeP
pure $ IntMap.insert relativeOffset' (DefaultUVSOffset varSelector' valueRanges :| []) accumulator
@ -734,7 +734,7 @@ cmapFormat14TableP = do
| otherwise = do
currentOffset <- Megaparsec.getOffset
let emptyBytes = tableOffset + fromIntegral relativeOffset - currentOffset
Megaparsec.takeP Nothing emptyBytes
void $ Megaparsec.takeP Nothing emptyBytes
entryCount <- fromIntegral <$> Megaparsec.Binary.word32be
flip (IntMap.insert $ fromIntegral relativeOffset) accumulator
. pure
@ -1135,15 +1135,15 @@ bContrastP
bStrokeVariationP :: Parser BStrokeVariation
bStrokeVariationP
= (Megaparsec.single 0 $> AnyStrokeVariatoon)
<|> (Megaparsec.single 1 $> NoFitStrokeVariatoon)
<|> (Megaparsec.single 2 $> GradualDiagonalStrokeVariatoon)
<|> (Megaparsec.single 3 $> GradualTransitionalStrokeVariatoon)
<|> (Megaparsec.single 4 $> GradualVerticalStrokeVariatoon)
<|> (Megaparsec.single 5 $> GradualHorizontalStrokeVariatoon)
<|> (Megaparsec.single 6 $> RapidVerticalStrokeVariatoon)
<|> (Megaparsec.single 7 $> RapidHorizontalStrokeVariatoon)
<|> (Megaparsec.single 8 $> InstantVerticalStrokeVariatoon)
= (Megaparsec.single 0 $> AnyStrokeVariation)
<|> (Megaparsec.single 1 $> NoFitStrokeVariation)
<|> (Megaparsec.single 2 $> GradualDiagonalStrokeVariation)
<|> (Megaparsec.single 3 $> GradualTransitionalStrokeVariation)
<|> (Megaparsec.single 4 $> GradualVerticalStrokeVariation)
<|> (Megaparsec.single 5 $> GradualHorizontalStrokeVariation)
<|> (Megaparsec.single 6 $> RapidVerticalStrokeVariation)
<|> (Megaparsec.single 7 $> RapidHorizontalStrokeVariation)
<|> (Megaparsec.single 8 $> InstantVerticalStrokeVariation)
<?> "bStrokeVariation"
bArmStyleP :: Parser BArmStyle

View File

@ -627,7 +627,32 @@ data BFamilyType
| ScriptFamilyType
| DecorativeFamilyType
| PictorialFamilyType
deriving (Eq, Show)
deriving Eq
instance Show BFamilyType
where
show AnyFamilyType = "Any"
show NoFitFamilyType = "No Fit"
show TextAndDisplayFamilyType = "Text and Display"
show ScriptFamilyType = "Script"
show DecorativeFamilyType = "Decorative"
show PictorialFamilyType = "Pictorial"
instance Enum BFamilyType
where
toEnum 0 = AnyFamilyType
toEnum 1 = NoFitFamilyType
toEnum 2 = TextAndDisplayFamilyType
toEnum 3 = ScriptFamilyType
toEnum 4 = DecorativeFamilyType
toEnum 5 = PictorialFamilyType
toEnum _ = error "Unknown family type"
fromEnum AnyFamilyType = 0
fromEnum NoFitFamilyType = 1
fromEnum TextAndDisplayFamilyType = 2
fromEnum ScriptFamilyType = 3
fromEnum DecorativeFamilyType = 4
fromEnum PictorialFamilyType = 5
data BSerifStyle
= AnySerifStyle
@ -646,7 +671,62 @@ data BSerifStyle
| PerpSansSerifStyle
| FlaredSerifStyle
| RoundedSerifStyle
deriving (Eq, Show)
deriving Eq
instance Show BSerifStyle
where
show AnySerifStyle = "Any"
show NoFitSerifStyle = "No Fit"
show CoveSerifStyle = "Cove"
show ObtuseCoveSerifStyle = "Obtuse Cove"
show SquareCoveSerifStyle = "Square Cove"
show ObtuseSquareCoveSerifStyle = "Obtuse Square Cove"
show SquareSerifStyle = "Square"
show ThinSerifStyle = "Thin"
show BoneSerifStyle = "Bone"
show ExaggeratedSerifStyle = "Exaggerated"
show TriangleSerifStyle = "Triangle"
show NormalSansSerifStyle = "Normal Sans"
show ObtuseSansSerifStyle = "Obtuse Sans"
show PerpSansSerifStyle = "Perp Sans"
show FlaredSerifStyle = "Flared"
show RoundedSerifStyle = "Rounded"
instance Enum BSerifStyle
where
toEnum 0 = AnySerifStyle
toEnum 1 = NoFitSerifStyle
toEnum 2 = CoveSerifStyle
toEnum 3 = ObtuseCoveSerifStyle
toEnum 4 = SquareCoveSerifStyle
toEnum 5 = ObtuseSquareCoveSerifStyle
toEnum 6 = SquareSerifStyle
toEnum 7 = ThinSerifStyle
toEnum 8 = BoneSerifStyle
toEnum 9 = ExaggeratedSerifStyle
toEnum 10 = TriangleSerifStyle
toEnum 11 = NormalSansSerifStyle
toEnum 12 = ObtuseSansSerifStyle
toEnum 13 = PerpSansSerifStyle
toEnum 14 = FlaredSerifStyle
toEnum 15 = RoundedSerifStyle
toEnum _ = error "Unknown serif type"
fromEnum AnySerifStyle = 0
fromEnum NoFitSerifStyle = 1
fromEnum CoveSerifStyle = 2
fromEnum ObtuseCoveSerifStyle = 3
fromEnum SquareCoveSerifStyle = 4
fromEnum ObtuseSquareCoveSerifStyle = 5
fromEnum SquareSerifStyle = 6
fromEnum ThinSerifStyle = 7
fromEnum BoneSerifStyle = 8
fromEnum ExaggeratedSerifStyle = 9
fromEnum TriangleSerifStyle = 10
fromEnum NormalSansSerifStyle = 11
fromEnum ObtuseSansSerifStyle = 12
fromEnum PerpSansSerifStyle = 13
fromEnum FlaredSerifStyle = 14
fromEnum RoundedSerifStyle = 15
data BWeight
= AnyWeight
@ -661,7 +741,50 @@ data BWeight
| HeavyWeight
| BlackWeight
| NordWeight
deriving (Eq, Show)
deriving Eq
instance Show BWeight
where
show AnyWeight = "Any"
show NoFitWeight = "No Fit"
show VeryLightWeight = "Very Light"
show LightWeight = "Light"
show ThinWeight = "Thin"
show BookWeight = "Book"
show MediumWeight = "Medium"
show DemiWeight = "Demi"
show BoldWeight = "Bold"
show HeavyWeight = "Heavy"
show BlackWeight = "Black"
show NordWeight = "Nord"
instance Enum BWeight
where
fromEnum AnyWeight = 0
fromEnum NoFitWeight = 1
fromEnum VeryLightWeight = 2
fromEnum LightWeight = 3
fromEnum ThinWeight = 4
fromEnum BookWeight = 5
fromEnum MediumWeight = 6
fromEnum DemiWeight = 7
fromEnum BoldWeight = 8
fromEnum HeavyWeight = 9
fromEnum BlackWeight = 10
fromEnum NordWeight = 11
toEnum 0 = AnyWeight
toEnum 1 = NoFitWeight
toEnum 2 = VeryLightWeight
toEnum 3 = LightWeight
toEnum 4 = ThinWeight
toEnum 5 = BookWeight
toEnum 6 = MediumWeight
toEnum 7 = DemiWeight
toEnum 8 = BoldWeight
toEnum 9 = HeavyWeight
toEnum 10 = BlackWeight
toEnum 11 = NordWeight
toEnum _ = error "Unknown weight"
data BProportion
= AnyProportion
@ -674,7 +797,44 @@ data BProportion
| VeryExpandedProportion
| VeryCondensedProportion
| MonospacedProportion
deriving (Eq, Show)
deriving Eq
instance Show BProportion
where
show AnyProportion = "Any"
show NoFitProportion = "No Fit"
show OldStyleProportion = "Old Style"
show ModernProportion = "Modern"
show EvenWidthProportion = "Even Width"
show ExpandedProportion = "Expanded"
show CondensedProportion = "Condensed"
show VeryExpandedProportion = "Very Expanded"
show VeryCondensedProportion = "Very Condensed"
show MonospacedProportion = "Monospaced"
instance Enum BProportion
where
fromEnum AnyProportion = 0
fromEnum NoFitProportion = 1
fromEnum OldStyleProportion = 2
fromEnum ModernProportion = 3
fromEnum EvenWidthProportion = 4
fromEnum ExpandedProportion = 5
fromEnum CondensedProportion = 6
fromEnum VeryExpandedProportion = 7
fromEnum VeryCondensedProportion = 8
fromEnum MonospacedProportion = 9
toEnum 0 = AnyProportion
toEnum 1 = NoFitProportion
toEnum 2 = OldStyleProportion
toEnum 3 = ModernProportion
toEnum 4 = EvenWidthProportion
toEnum 5 = ExpandedProportion
toEnum 6 = CondensedProportion
toEnum 7 = VeryExpandedProportion
toEnum 8 = VeryCondensedProportion
toEnum 9 = MonospacedProportion
toEnum _ = error "Unknown proportion"
data BContrast
= AnyContrast
@ -687,19 +847,90 @@ data BContrast
| MediumHighContrast
| HighContrast
| VeryHighContrast
deriving (Eq, Show)
deriving Eq
instance Show BContrast
where
show AnyContrast = "Any"
show NoFitContrast = "No Fit"
show NoneContrast = "None"
show VeryLowContrast = "Very Low"
show LowContrast = "Low"
show MediumLowContrast = "Medium Low"
show MediumContrast = "Medium"
show MediumHighContrast = "Medium High"
show HighContrast = "High"
show VeryHighContrast = "Very High"
instance Enum BContrast
where
fromEnum AnyContrast = 0
fromEnum NoFitContrast = 1
fromEnum NoneContrast = 2
fromEnum VeryLowContrast = 3
fromEnum LowContrast = 4
fromEnum MediumLowContrast = 5
fromEnum MediumContrast = 6
fromEnum MediumHighContrast = 7
fromEnum HighContrast = 8
fromEnum VeryHighContrast = 9
toEnum 0 = AnyContrast
toEnum 1 = NoFitContrast
toEnum 2 = NoneContrast
toEnum 3 = VeryLowContrast
toEnum 4 = LowContrast
toEnum 5 = MediumLowContrast
toEnum 6 = MediumContrast
toEnum 7 = MediumHighContrast
toEnum 8 = HighContrast
toEnum 9 = VeryHighContrast
toEnum _ = error "Unknown contrast"
data BStrokeVariation
= AnyStrokeVariatoon
| NoFitStrokeVariatoon
| GradualDiagonalStrokeVariatoon
| GradualTransitionalStrokeVariatoon
| GradualVerticalStrokeVariatoon
| GradualHorizontalStrokeVariatoon
| RapidVerticalStrokeVariatoon
| RapidHorizontalStrokeVariatoon
| InstantVerticalStrokeVariatoon
deriving (Eq, Show)
= AnyStrokeVariation
| NoFitStrokeVariation
| GradualDiagonalStrokeVariation
| GradualTransitionalStrokeVariation
| GradualVerticalStrokeVariation
| GradualHorizontalStrokeVariation
| RapidVerticalStrokeVariation
| RapidHorizontalStrokeVariation
| InstantVerticalStrokeVariation
deriving Eq
instance Show BStrokeVariation
where
show AnyStrokeVariation = "Any"
show NoFitStrokeVariation = "No Fit"
show GradualDiagonalStrokeVariation = "Gradual/Diagonal"
show GradualTransitionalStrokeVariation = "Gradual/Transitional"
show GradualVerticalStrokeVariation = "Gradual/Vertical"
show GradualHorizontalStrokeVariation = "Gradual/Horizontal"
show RapidVerticalStrokeVariation = "Rapid/Vertical"
show RapidHorizontalStrokeVariation = "Rapid/Horizontal"
show InstantVerticalStrokeVariation = "Instant/Vertical"
instance Enum BStrokeVariation
where
fromEnum AnyStrokeVariation = 0
fromEnum NoFitStrokeVariation = 1
fromEnum GradualDiagonalStrokeVariation = 2
fromEnum GradualTransitionalStrokeVariation = 3
fromEnum GradualVerticalStrokeVariation = 4
fromEnum GradualHorizontalStrokeVariation = 5
fromEnum RapidVerticalStrokeVariation = 6
fromEnum RapidHorizontalStrokeVariation = 7
fromEnum InstantVerticalStrokeVariation = 8
toEnum 0 = AnyStrokeVariation
toEnum 1 = NoFitStrokeVariation
toEnum 2 = GradualDiagonalStrokeVariation
toEnum 3 = GradualTransitionalStrokeVariation
toEnum 4 = GradualVerticalStrokeVariation
toEnum 5 = GradualHorizontalStrokeVariation
toEnum 6 = RapidVerticalStrokeVariation
toEnum 7 = RapidHorizontalStrokeVariation
toEnum 8 = InstantVerticalStrokeVariation
toEnum _ = error "Unknown stroke variation"
data BArmStyle
= AnyArmStyle
@ -714,7 +945,50 @@ data BArmStyle
| NonStraightArmsVerticalArmStyle
| NonStraightArmsSingleSerifArmStyle
| NonStraightArmsDoubleSerifArmStyle
deriving (Eq, Show)
deriving Eq
instance Show BArmStyle
where
show AnyArmStyle = "Any"
show NoFitArmStyle = "No Fit"
show StraightArmsHorizontalArmStyle = "Straight Arms/Horizontal"
show StraightArmsWedgeArmStyle = "Straight Arms/Wedge"
show StraightArmsVerticalArmStyle = "Straight Arms/Vertical"
show StraightArmsSingleSerifArmStyle = "Straight Arms/Single Serif"
show StraightArmsDoubleSerifArmStyle = "Straight Arms/Double Serif"
show NonStraightArmsHorizontalArmStyle = "Non-Straight Arms/Horizontal"
show NonStraightArmsWedgeArmStyle = "Non-Straight Arms/Wedge"
show NonStraightArmsVerticalArmStyle = "Non-Straight Arms/Vertical"
show NonStraightArmsSingleSerifArmStyle = "Non-Straight Arms/Single Serif"
show NonStraightArmsDoubleSerifArmStyle = "Non-Straight Arms/Double Serif"
instance Enum BArmStyle
where
fromEnum AnyArmStyle = 0
fromEnum NoFitArmStyle = 1
fromEnum StraightArmsHorizontalArmStyle = 2
fromEnum StraightArmsWedgeArmStyle = 3
fromEnum StraightArmsVerticalArmStyle = 4
fromEnum StraightArmsSingleSerifArmStyle = 5
fromEnum StraightArmsDoubleSerifArmStyle = 6
fromEnum NonStraightArmsHorizontalArmStyle = 7
fromEnum NonStraightArmsWedgeArmStyle = 8
fromEnum NonStraightArmsVerticalArmStyle = 9
fromEnum NonStraightArmsSingleSerifArmStyle = 10
fromEnum NonStraightArmsDoubleSerifArmStyle = 11
toEnum 0 = AnyArmStyle
toEnum 1 = NoFitArmStyle
toEnum 2 = StraightArmsHorizontalArmStyle
toEnum 3 = StraightArmsWedgeArmStyle
toEnum 4 = StraightArmsVerticalArmStyle
toEnum 5 = StraightArmsSingleSerifArmStyle
toEnum 6 = StraightArmsDoubleSerifArmStyle
toEnum 7 = NonStraightArmsHorizontalArmStyle
toEnum 8 = NonStraightArmsWedgeArmStyle
toEnum 9 = NonStraightArmsVerticalArmStyle
toEnum 10 = NonStraightArmsSingleSerifArmStyle
toEnum 11 = NonStraightArmsDoubleSerifArmStyle
toEnum _ = error "Unknown arm style"
data BLetterform
= AnyLetterform