def ttf.location
gralha-truetype@0.1.0.1 · font.bend:145
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
145
146def ttf.location(+b: Bin.Bytes, +f: TTFont, +gid: U32) -> U32 & U32:
147 TTFont{glyf, loca, long, hmtx, metrics, glyphs, units} = f
148 +lo = loca
149 +lg = long
150 +a = U.choose(U32, lg, ttf.u32(b, (lo + gid * 4 : U32)), (ttf.u16(b, (lo + gid * 2 : U32)) * 2 : U32))
151 +c = U.choose(U32, lg, ttf.u32(b, (lo + gid * 4 + 4 : U32)), (ttf.u16(b, (lo + gid * 2 + 2 : U32)) * 2 : U32))
152 ((glyf + a : U32), U.choose(U32, U32.is_lt(gid, glyphs) && U32.is_gt(c, a), (c - a : U32), 0))