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
|
<> foldMap dumpEndPoint (Vector.indexed endPtsOfContours) <> newlineBuilder
|
||||||
<> " Length of Instructions: "
|
<> " Length of Instructions: "
|
||||||
<> Text.Builder.decimal (Vector.length instructions) <> newlineBuilder
|
<> Text.Builder.decimal (Vector.length instructions) <> newlineBuilder
|
||||||
<> " Flags" <> newlineBuilder
|
<> newlineBuilder <> " Flags" <> newlineBuilder
|
||||||
<> " -----" <> newlineBuilder
|
<> " -----" <> newlineBuilder
|
||||||
<> foldMap dumpFlag (Vector.indexed coordinates) <> newlineBuilder <> newlineBuilder
|
<> foldMap dumpFlag (Vector.indexed coordinates) <> newlineBuilder
|
||||||
dumpGlyphDefinition _ = ""
|
<> " Coordinates" <> newlineBuilder
|
||||||
dumpFlag (coordinateIndex, GlyphCoordinate{..})
|
<> " -----------" <> newlineBuilder
|
||||||
|
<> dumpCoordinates coordinates
|
||||||
|
dumpGlyphDefinition _ = "" -- TODO
|
||||||
|
dumpFlag (coordinateIndex, GlyphCoordinate{..}) -- TODO
|
||||||
= " " <> justifyNumber 2 coordinateIndex <> ": "
|
= " " <> justifyNumber 2 coordinateIndex <> ": "
|
||||||
<> Text.Builder.decimal coordinateX <> " " <> Text.Builder.decimal coordinateY <> " "
|
|
||||||
<> (if onCurve then "On" else "Off")
|
<> (if onCurve then "On" else "Off")
|
||||||
<> newlineBuilder
|
<> 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
|
dumpTables
|
||||||
:: Megaparsec.State ByteString Void
|
:: Megaparsec.State ByteString Void
|
||||||
|
Loading…
Reference in New Issue
Block a user