code wiki / _hdl_build / nx_font_advdiff.nx

nx_font_advdiff.nx

buildroot/runtime/_hdl_build/nx_font_advdiff.nx

4696 B102 linesdepth 4pulls 5 transitivereach 0 importersview sourcekind tooltopic font
docsdependenciesstructsconstsfunctions

about

nx_font_advdiff.nx -- FONT-METRICS DRIFT instrument (operator 2026-07-28: "use free fonts as another benchmark -- make sure the browser isn't held back by something dumb like that"). Reads a real TTF's cmap(format 4) + hmtx and prints, for ASCII 32..126, the font's advance in 1000/em units next to OUR font_adv_em(ch), plus the drift. Wrap points come from summed advances, so per-char drift vs Arial (Chrome's default sans; metrics == Liberation Sans, SIL-OFL) IS the structural-exactness gap of every line break. usage: nx_font_advdiff <path.ttf>

dependencies 2 imports · 0 importers

nx_syscalls.nx nx_font.nx nx_font_advdiff.nx

imports: nx_syscalls.nxnx_font.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main w sys_write sys_exit sys_mmap sys_read_file sys_openat_rd sys_lseek sys_mmap ↻ sys_read sys_close u16 tag_is u32 u16 ↻ n2 sys_mmap ↻ w ↻ sys_write ↻ font_adv_em font_adv_em_base font_adv_em_base_geo font_ws font_wdth

structs

none

consts

9const K_MAGIC_65536: i64 = 65536

functions

11func w(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 }
called by 2: n2main calls 1: sys_write
12func n2(v: i64) -> i64 { let b: *u8=sys_mmap(28); var m: i64=v; if m<0{w("-" as *u8);m=0-m} let t: *u8=sys_mmap(28); var k: i64=0; if m==0{t[0]=48 as u8;k=1} while m>0{t[k]=(48+(m%10)) as u8;m=m/10;k=k+1} var i: i64=0; while i<k{b[i]=t[k-1-i];i=i+1} sys_write(1,b,k); return 0 }
called by 1: main calls 3: sys_mmapwsys_write
13func u16(p: *u8, o: i64) -> i64 { return ((p[o]&0xff)*256) + (p[o+1]&0xff) }
called by 2: u32main
14func u32(p: *u8, o: i64) -> i64 { return (u16(p,o)*K_MAGIC_65536) + u16(p,o+2) }
called by 1: main calls 1: u16
15func tag_is(p: *u8, o: i64, a: i64, b: i64, c: i64, d: i64) -> i64
called by 1: main
20func main(argc: i64, argv: *i64) -> i64