def text.anchor.nodes
gralha-svg-render@0.1.0.1 · svg.bend:3543
import gralha-svg-render@0.1.0.1/svg.bend as Svg
import Base
import gralha-text-scan@0.1.0.1/scan.bend as U
import gralha-xml-doc@0.1.0.1/xml.bend as XML
3543def text.anchor.nodes(+xs: List<&2, XML.Element>, +chunks: List<&2, TextChunk>, +skip: String) -> List<&2, XML.Element>:
3544 match xs:
3545 case Nil{}: Nil{}
3546 case Con{XML.Element{n, attrs, kids, txt}, rest}:
3547 +tagname = n
3548 +as = attrs
3549 +glyph = U.string.equal(tagname, "#glyph")
3550 +shift = text.chunk.shift(chunks, F32.to_u32(U.scalar(XML.attr.get(as, "#text-chunk", "0"), 0.0)))
3551 +mat = matrix.mul(translate(F32.neg(shift), 0.0), transform(XML.attr.get(as, "#glyph-transform", ""), identity()))
3552 U.branch(List<&2, XML.Element>, glyph && U.string.equal(XML.attr.get(as, "#text-index", ""), skip),
3553 _ => text.anchor.nodes(rest, chunks, skip),
3554 _ => Con{XML.Element{tagname, U.choose(List<&2, XML.Attr>, glyph, Con{XML.Attr{"#glyph-transform", matrix.show(mat)}, as}, as),
3555 text.anchor.nodes(kids, chunks, skip), txt}, text.anchor.nodes(rest, chunks, skip)})