def ttf.flags

gralha-truetype@0.1.0.1 · font.bend:182

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

182# Point flags with repeat counts expanded; returns the flags and the next byte offset.
183def ttf.flags(+b: Bin.Bytes, n: Nat, +at: U32, +pending: U32, +last: U32) -> List<&2, U32> & U32:
184  match n:
185    case 0n: (Nil{}, at)
186    case 1n+d:
187      +dd = d
188      +f = ttf.u8(b, at)
189      U.branch(List<&2, U32> & U32, U32.is_gt(pending, 0),
190        _ => ttf.after.flag(last, ttf.flags(b, dd, at, (pending - 1 : U32), last)),
191        _ => U.branch(List<&2, U32> & U32, ttf.bit(f, 8),
192          _ => ttf.after.flag(f, ttf.flags(b, dd, (at + 2 : U32), ttf.u8(b, (at + 1 : U32)), f)),
193          _ => ttf.after.flag(f, ttf.flags(b, dd, (at + 1 : U32), 0, f))))

Uses (13)

Used by (1)