code wiki / (root) / nx_font_ttf_emit.nx

nx_font_ttf_emit.nx

buildroot/runtime/nx_font_ttf_emit.nx

14186 B231 linesdepth 3pulls 3 transitivereach 0 importersview sourcekind tooltopic font
docsdependenciesstructsconstsfunctions

about

nx_font_ttf_emit.nx -- R2 of the sovereign-font ladder (the KEYSTONE): serialize the R1 glyph outline model into a REAL TrueType .ttf (sfnt: OS/2 cmap glyf head hhea hmtx loca maxp name post, big-endian, per-table checksums + head.checkSumAdjustment) -> web_assets/nishi.ttf. Then SELF-VALIDATE by re-parsing the emitted bytes (sfntVersion, numTables, every dir offset/length in bounds, every table checksum recomputed [head special], and the whole-file checksum == 0xB1B0AFBA) -> sovereign verification, not assumed. Glyphs: .notdef space H I T, in-house designs, 1000-EM. license_tier: ORIGINAL expect_exit: 0

dependencies 1 imports · 0 importers

nx_syscalls_x86_64.nx nx_font_ttf_emit.nx

imports: nx_syscalls_x86_64.nx

imported by: nobody (leaf or entry point)

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

main fill_notdef append_glyph w16 si16 w8 fill_space fill_H fill_I fill_T align4 w16 ↻ si16 ↻ w8 ↻ w32 csum r32 utf16be w8 ↻ sys_openat_wr sw sn r32 ↻ r16

structs

none

consts

8const MAGIC_MAGIC_65536: i64 = 65536
9const MAGIC_MAGIC_16777216: i64 = 16777216
10const MAGIC_MAGIC_4294967296: i64 = 4294967296
11const MAGIC_MAGIC_4096: i64 = 4096
12const MAGIC_MAGIC_16384: i64 = 16384
13const MAGIC_MAGIC_65535: i64 = 65535
14const MAGIC_MAGIC_65505: i64 = 65505
15const MAGIC_MAGIC_65466: i64 = 65466
16const MAGIC_MAGIC_65456: i64 = 65456
17const MAGIC_MAGIC_1594834165: i64 = 1594834165
18const MAGIC_MAGIC_1033: i64 = 1033
19const MAGIC_MAGIC_196608: i64 = 196608
21const MAGIC_ADJ: i64 = 2981146554 // 0xB1B0AFBA

functions

23func sw(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 1: main
24func sn(v: i64) -> i64 { let bb: *u8=sys_mmap(28); var m: i64=v; if m<0{m=0-m;sys_write(1,"-" as *u8,1)} 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{bb[i]=t[k-1-i];i=i+1} sys_write(1,bb,k); return 0 }
called by 1: main
26func si16(v: i64) -> i64 { if v<0 { return v+MAGIC_MAGIC_65536 } return v }
called by 2: append_glyphmain
27func w8(b: *u8, o: i64, v: i64) -> i64 { b[o]=(v%256) as u8; return o+1 }
28func w16(b: *u8, o: i64, v: i64) -> i64 { b[o]=((v/256)%256) as u8; b[o+1]=(v%256) as u8; return o+2 }
called by 2: append_glyphmain
29func w32(b: *u8, o: i64, v: i64) -> i64 { b[o]=((v/MAGIC_MAGIC_16777216)%256) as u8; b[o+1]=((v/MAGIC_MAGIC_65536)%256) as u8; b[o+2]=((v/256)%256) as u8; b[o+3]=(v%256) as u8; return o+4 }
called by 1: main
30func r16(b: *u8, o: i64) -> i64 { return (b[o] as i64)*256 + (b[o+1] as i64) }
called by 1: main
31func r32(b: *u8, o: i64) -> i64 { return (b[o] as i64)*MAGIC_MAGIC_16777216 + (b[o+1] as i64)*MAGIC_MAGIC_65536 + (b[o+2] as i64)*256 + (b[o+3] as i64) }
called by 2: csummain
32func align4(o: i64) -> i64 { while o%4 != 0 { o=o+1 } return o }
called by 1: main
33func csum(b: *u8, off: i64, len: i64) -> i64 { var s: i64=0; var i: i64=off; while i < off+len { s = (s + r32(b,i)) % MAGIC_MAGIC_4294967296; i=i+4 } return s }
called by 1: main calls 1: r32
34func utf16be(b: *u8, o: i64, s: *u8) -> i64 { var oo: i64=o; var i: i64=0; while s[i]!=(0 as u8) { oo=w8(b,oo,0); oo=w8(b,oo,s[i] as i64); i=i+1 } return oo }
called by 1: main calls 1: w8
37func fill_notdef(ep: *i64, px: *i64, py: *i64, meta: *i64) -> i64 { px[0]=80;py[0]=0;px[1]=520;py[1]=0;px[2]=520;py[2]=700;px[3]=80;py[3]=700; ep[0]=3;meta[0]=1;meta[1]=4; return 0 }
called by 1: main
38func fill_space(ep: *i64, px: *i64, py: *i64, meta: *i64) -> i64 { meta[0]=0;meta[1]=0; return 0 }
called by 1: main
39func fill_H(ep: *i64, px: *i64, py: *i64, meta: *i64) -> i64
called by 1: main
44func fill_I(ep: *i64, px: *i64, py: *i64, meta: *i64) -> i64 { px[0]=250;py[0]=0;px[1]=400;py[1]=0;px[2]=400;py[2]=700;px[3]=250;py[3]=700; ep[0]=3;meta[0]=1;meta[1]=4; return 0 }
called by 1: main
45func fill_T(ep: *i64, px: *i64, py: *i64, meta: *i64) -> i64
called by 1: main
51func append_glyph(g: *u8, go: i64, ep: *i64, px: *i64, py: *i64, meta: *i64) -> i64
called by 1: main calls 3: w16si16w8
68func main() -> i64