code wiki / _hdl_build / nx_font_space_tool.nx
nx_font_space_tool.nx
buildroot/runtime/_hdl_build/nx_font_space_tool.nx
about
nx_font_space_tool.nx -- AUTO-SPACING generator (the fix for "ransom-note rhythm"): per-glyph OPTICAL
sidebearings, computed not hand-set. Method (Tracy/FontForge-autowidth class): render each glyph through
the REAL engine, measure its ink extents in the OPTICAL BAND (x-height middle, 350..650em -- where the
eye reads letter spacing), allow diagonals/serif-tips to overhang the band extent by DIAG_ALLOW, then set
shift(ch) = SB_T - eff_left (moves the glyph so its optical left edge sits at SB_T)
adv(ch) = SB_T + eff_width + SB_T
so EVERY pair gap reads ~2*SB_T -> even rhythm (kerning of specific pairs = a later refinement axis).
EMITS the tables as NishiLang code on stdout (build generators, not artifacts) -> pasted into nx_font.nx
marked GENERATED-BY; rerun this tool after any glyph-geometry change. license_tier: ORIGINAL expect_exit: 0
dependencies 2 imports · 0 importers
imports: nx_font.nxnx_aa_raster.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
| 12 | const SB_MAGIC_60000: i64 = 60000 |
| 13 | const SB_MAGIC_6000: i64 = 6000 |
| 18 | const CW: i64 = 260 // canvas px (em/5 + margins) |
| 19 | const CH2: i64 = 280 |
| 20 | const MX: i64 = 20 // margin px |
| 21 | const SPX: i64 = 200 // em -> px scale (S): 1000em = 200px, 1px = 5em |
| 22 | const SB_T: i64 = 50 // target optical sidebearing (em) |
| 23 | const DIAG_ALLOW: i64 = 35 // how far diagonals may overhang the optical edge (em) |
functions
| 15 | func st_puts(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 |
| 16 | func st_num(v: i64) -> i64 { let b: *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{b[i]=t[k-1-i];i=i+1} sys_write(1,b,k); return 0 } called by 1: main |
| 25 | func main() -> i64 |