def ttf.coords

gralha-truetype@0.1.0.1 · font.bend:199

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

199# One coordinate axis: short bytes with a sign flag, repeated values, or signed word deltas.
200def ttf.coords(+b: Bin.Bytes, flags: List<&2, U32>, +at: U32, +prev: F32, +short: U32, +same: U32) -> List<&2, F32> & U32:
201  match flags:
202    case Nil{}: (Nil{}, at)
203    case Con{f, rest}:
204      +fl = f
205      +isShort = ttf.bit(fl, short)
206      +isSame = ttf.bit(fl, same)
207      +v = U.branch(F32, isShort, _ => (prev + U.choose(F32, isSame, 1.0, F32.neg(1.0)) * U32.to_f32(ttf.u8(b, at)) : F32),
208        _ => U.branch(F32, isSame, _ => prev, _ => (prev + ttf.i16(b, at) : F32)))
209      ttf.after.coord(v, ttf.coords(b, rest, (at + U.choose(U32, isShort, 1, U.choose(U32, isSame, 0, 2)) : U32), v, short, same))

Uses (17)

Used by (2)