def text.bounds
gralha-svg-render@0.1.0.1 · svg.bend:3593
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
3593def text.bounds(xs: List<&2, XML.Element>, +matrix: Matrix, +box: Bounds) -> Bounds:
3594 match xs:
3595 case Nil{}: box
3596 case Con{XML.Element{n, as, kids, txt}, rest}:
3597 +attrs = as
3598 +mat = matrix.mul(matrix, transform(XML.attr.get(attrs, "transform", ""), identity()))
3599 text.bounds(rest, matrix, text.bounds(kids, mat,
3600 U.branch(Bounds, U.string.equal(n, "#glyph"), _ => text.cell(matrix.mul(mat, transform(XML.attr.get(attrs, "#glyph-transform", ""), identity())),
3601 U.scalar(XML.attr.get(attrs, "#glyph-advance", "0"), 0.0), box), _ => box)))