code wiki / _hdl_build / nx_font_space_tool.nx

nx_font_space_tool.nx

buildroot/runtime/_hdl_build/nx_font_space_tool.nx

6222 B125 linesdepth 4pulls 5 transitivereach 0 importersview sourcekind tooltopic font
docsdependenciesstructsconstsfunctions

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

nx_font.nx nx_aa_raster.nx nx_font_space_tool.nx

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

main st_puts font_trig_init font_spec_reset font_emit font_emit_geo font_weight font_mod fe_ring fe_stroke fe_chaikin_cp gs_isqrt font_mod ↻ gs_isqrt ↻ font_ws font_wdth font_slant font_swell gs_stroke_var sys_mmap gs_isqrt ↻ gs_emit_oriented gs_area2 gs_disc geo_arc fe_stroke ↻ fe_stroke ↻ geo_earc fe_stroke ↻ font_weight ↻ font_mod ↻ font_ws ↻ font_wdth ↻ font_slant ↻ fe_stroke ↻ gs_disc ↻ fe_ring ↻ aa_render aa_inside st_num

structs

none

consts

12const SB_MAGIC_60000: i64 = 60000
13const SB_MAGIC_6000: i64 = 6000
18const CW: i64 = 260 // canvas px (em/5 + margins)
19const CH2: i64 = 280
20const MX: i64 = 20 // margin px
21const SPX: i64 = 200 // em -> px scale (S): 1000em = 200px, 1px = 5em
22const SB_T: i64 = 50 // target optical sidebearing (em)
23const DIAG_ALLOW: i64 = 35 // how far diagonals may overhang the optical edge (em)

functions

15func 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
16func 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
25func main() -> i64