nx_font_gen.nx
buildroot/runtime/nx_font_gen.nx
about
nx_font_gen.nx -- the GEN-AXES rung: a PARAMETRIC font GENERATOR (not one font). Glyphs are defined ONCE as
stroke CENTERLINES; a WEIGHT parameter (stroke radius) drives outline generation (each stroke -> a rectangle
contour, offset by the weight; multiple contours per glyph, TrueType nonzero-winding fills the union). ONE
definition -> a FAMILY: emits nishi_light/regular/bold.ttf (3 weights) from the same strokes, plus a comparison
page nishi_weights.html. Reuses the self-validated sfnt emitter (nx_font_ttf_emit) verbatim. Glyphs H I T (+
.notdef, space). These are 3 STATIC instances of the generator; the single-file VARIABLE font (gvar deltas) is
the next rung. license_tier: ORIGINAL expect_exit: 0
dependencies 1 imports · 0 importers
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
structs
| none |
consts
| 9 | const MAGIC_MAGIC_65536: i64 = 65536 |
| 10 | const MAGIC_MAGIC_16777216: i64 = 16777216 |
| 11 | const MAGIC_MAGIC_4294967296: i64 = 4294967296 |
| 12 | const MAGIC_MAGIC_4096: i64 = 4096 |
| 13 | const MAGIC_MAGIC_65535: i64 = 65535 |
| 14 | const MAGIC_MAGIC_65505: i64 = 65505 |
| 15 | const MAGIC_MAGIC_65466: i64 = 65466 |
| 16 | const MAGIC_MAGIC_65456: i64 = 65456 |
| 17 | const MAGIC_MAGIC_1594834165: i64 = 1594834165 |
| 18 | const MAGIC_MAGIC_1033: i64 = 1033 |
| 19 | const MAGIC_MAGIC_196608: i64 = 196608 |
| 20 | const MAGIC_MAGIC_262144: i64 = 262144 |
| 21 | const MAGIC_MAGIC_16384: i64 = 16384 |
| 23 | const MAGIC_ADJ: i64 = 2981146554 |
functions
| 25 | func 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 |
| 26 | func 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 |
| 28 | func si16(v: i64) -> i64 { if v<0 { return v+MAGIC_MAGIC_65536 } return v } |
| 29 | func w8(b: *u8, o: i64, v: i64) -> i64 { b[o]=(v%256) as u8; return o+1 } |
| 30 | func 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 } |
| 31 | func 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: emit_ttf |
| 32 | func r16(b: *u8, o: i64) -> i64 { return (b[o] as i64)*256 + (b[o+1] as i64) } |
| 33 | func 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 1: csum |
| 34 | func align4(o: i64) -> i64 { while o%4 != 0 { o=o+1 } return o } called by 1: emit_ttf |
| 35 | func 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 } |
| 36 | func he_puts(buf: *u8, off: i64, s: *u8) -> i64 { var o: i64=off; var i: i64=0; while s[i]!=0 { buf[o]=s[i]; o=o+1; i=i+1 } return o } |
| 38 | func b64c(v: i64) -> i64 { if v<26 { return 65+v } if v<52 { return 97+(v-26) } if v<62 { return 48+(v-52) } if v==62 { return 43 } return 47 } called by 1: b64_encode |
| 39 | func b64_encode(inb: *u8, n: i64, out: *u8) -> i64 |
| 50 | func add_rect(px: *i64, py: *i64, ep: *i64, pc: i64, cc: i64, x0: i64, y0: i64, x1: i64, y1: i64) -> i64 called by 1: gen_glyph |
| 56 | func gen_glyph(gid: i64, wr: i64, ep: *i64, px: *i64, py: *i64, meta: *i64) -> i64 |
| 73 | func append_glyph(g: *u8, go: i64, ep: *i64, px: *i64, py: *i64, meta: *i64) -> i64 |
| 91 | func emit_ttf(buf: *u8, wr: i64) -> i64 |
| 198 | func main() -> i64 |