def text.fit.nodes

gralha-svg-render@0.1.0.1 · svg.bend:3465

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

3465def text.fit.nodes(+xs: List<&2, XML.Element>, +origin: F32, +ratio: F32, +step: F32, +skip: String, +count: U32, +fixed: F32) -> TextFit:
3466  match xs:
3467    case Nil{}: TextFit{Nil{}, count, fixed}
3468    case Con{XML.Element{n, as, kids, txt}, rest}:
3469      +attrs = as
3470      +tagname = n
3471      +locked = U.string.equal(XML.attr.get(attrs, "#length-fixed", ""), "yes")
3472      +glyph = U.string.equal(tagname, "#glyph")
3473      +x = U.scalar(XML.attr.get(attrs, "#length-x", "0"), 0.0)
3474      +delta = ((x - origin - fixed) * (ratio - 1.0) + U32.to_f32(count) * step : F32)
3475      text.fit.then(U.branch(TextFit, locked || (glyph && Bool.not(U.string.equal(XML.attr.get(attrs, "#text-index", ""), skip))),
3476        _ => TextFit{Con{XML.Element{tagname, text.length.attrs(attrs, U.choose(F32, locked, 1.0, ratio), delta),
3477          text.length.translate(kids, delta), txt}, Nil{}}, U32.inc(count), (fixed + U.choose(F32, locked, U.scalar(XML.attr.get(attrs, "#length-width", "0"), 0.0), 0.0) : F32)},
3478        _ => text.fit.group(tagname, attrs, txt, text.fit.nodes(kids, origin, ratio, step, skip, count, fixed))),
3479        nextCount => nextFixed => text.fit.nodes(rest, origin, ratio, step, skip, nextCount, nextFixed))

Uses (23)

Used by (1)