def ttf.cmap.pick
gralha-truetype@0.1.0.1 · font.bend:658
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
658def ttf.cmap.pick(+b: Bin.Bytes, n: Nat, +cmap: U32, +at: U32, +best: U32, +score: U32) -> U32:
659 match n:
660 case 0n: best
661 case 1n+d:
662 +dd = d
663 +s = ttf.cmap.score(ttf.u16(b, at), ttf.u16(b, (at + 2 : U32)))
664 U.branch(U32, U32.is_gt(s, score),
665 _ => ttf.cmap.pick(b, dd, cmap, (at + 8 : U32), (cmap + ttf.u32(b, (at + 4 : U32)) : U32), s),
666 _ => ttf.cmap.pick(b, dd, cmap, (at + 8 : U32), best, score))