Dump glyph coordinates
This commit is contained in:
parent
1cce3c893d
commit
22d37b0972
@ -662,15 +662,41 @@ dumpGlyf (GlyfTable glyfDescriptions) = dumpCaption "'glyf' Table - Glyf data"
|
||||
<> foldMap dumpEndPoint (Vector.indexed endPtsOfContours) <> newlineBuilder
|
||||
<> " Length of Instructions: "
|
||||
<> Text.Builder.decimal (Vector.length instructions) <> newlineBuilder
|
||||
<> " Flags" <> newlineBuilder
|
||||
<> newlineBuilder <> " Flags" <> newlineBuilder
|
||||
<> " -----" <> newlineBuilder
|
||||
<> foldMap dumpFlag (Vector.indexed coordinates) <> newlineBuilder <> newlineBuilder
|
||||
dumpGlyphDefinition _ = ""
|
||||
dumpFlag (coordinateIndex, GlyphCoordinate{..})
|
||||
<> foldMap dumpFlag (Vector.indexed coordinates) <> newlineBuilder
|
||||
<> " Coordinates" <> newlineBuilder
|
||||
<> " -----------" <> newlineBuilder
|
||||
<> dumpCoordinates coordinates
|
||||
dumpGlyphDefinition _ = "" -- TODO
|
||||
dumpFlag (coordinateIndex, GlyphCoordinate{..}) -- TODO
|
||||
= " " <> justifyNumber 2 coordinateIndex <> ": "
|
||||
<> Text.Builder.decimal coordinateX <> " " <> Text.Builder.decimal coordinateY <> " "
|
||||
<> (if onCurve then "On" else "Off")
|
||||
<> newlineBuilder
|
||||
dumpCoordinates coordinates =
|
||||
let initial = ("", GlyphCoordinate 0 0 True)
|
||||
in fst $ Vector.ifoldl' foldCoordinate initial coordinates
|
||||
foldCoordinate
|
||||
:: (Text.Builder.Builder, GlyphCoordinate)
|
||||
-> Int
|
||||
-> GlyphCoordinate
|
||||
-> (Text.Builder.Builder, GlyphCoordinate)
|
||||
foldCoordinate (accumulator, absCoordinate) coordinateIndex relCoordinate =
|
||||
let nextAbs = GlyphCoordinate
|
||||
{ coordinateX = sumCoordinate (getField @"coordinateX") relCoordinate absCoordinate
|
||||
, coordinateY = sumCoordinate (getField @"coordinateY") relCoordinate absCoordinate
|
||||
, onCurve = getField @"onCurve" relCoordinate -- Not used.
|
||||
}
|
||||
newLine = " " <> justifyNumber 2 coordinateIndex
|
||||
<> " Rel " <> dumpCoordinate relCoordinate
|
||||
<> " -> Abs " <> dumpCoordinate nextAbs
|
||||
<> newlineBuilder
|
||||
in (accumulator <> newLine, nextAbs)
|
||||
sumCoordinate getAxis relCoordinate absCoordinate =
|
||||
getAxis relCoordinate + getAxis absCoordinate
|
||||
dumpCoordinate GlyphCoordinate{..}
|
||||
= "(" <> justifyNumber 7 coordinateX <> ", "
|
||||
<> justifyNumber 7 coordinateY <> ")"
|
||||
|
||||
dumpTables
|
||||
:: Megaparsec.State ByteString Void
|
||||
|
Loading…
Reference in New Issue
Block a user