def ttf.classdef.ranges
gralha-truetype@0.1.0.1 · font.bend:618
import gralha-truetype@0.1.0.1/font.bend as Font
import Base
import gralha-text-scan@0.1.0.1/scan.bend as U
import gralha-bytes@0.1.0.1/bytes.bend as Bin
618def ttf.classdef.ranges(+b: Bin.Bytes, fuel: Nat, +base: U32, +lo: U32, +hi: U32, +gid: U32) -> U32:
619 match fuel:
620 case 0n: 0
621 case 1n+d:
622 +dd = d
623 +mid = U32.div((lo + hi : U32), 2)
624 +at = (base + mid * 6 : U32)
625 +start = ttf.u16(b, at)
626 +end = ttf.u16(b, (at + 2 : U32))
627 U.branch(U32, U32.is_ge(lo, hi), _ => 0,
628 _ => U.branch(U32, U32.is_lt(gid, start), _ => ttf.classdef.ranges(b, dd, base, lo, mid, gid),
629 _ => U.branch(U32, U32.is_gt(gid, end), _ => ttf.classdef.ranges(b, dd, base, (mid + 1 : U32), hi, gid), _ => ttf.u16(b, (at + 4 : U32)))))