code wiki / _hdl_build / nx_font_test.nx
nx_font_test.nx source
↩ module page · 38 lines · 1326 B
1// nx_font_test.nx -- R4 engine proof: render a STRING through the font engine (font_text drives the builder
2// char-by-char) -> _offc/nx_aa_phrase.png. Table-driven smooth sovereign text, the layer the browser calls.
3import "nx_font.nx"
4import "nx_glyph_stroke.nx"
5import "nx_aa_raster.nx"
6import "nx_png_write.nx"
7
8func main() -> i64 {
9 let W: i64 = 230
10 let H: i64 = 80
11 let ss: i64 = 4
12
13 let cs: *i64 = sys_mmap(8*16) as *i64
14 let sn: *i64 = sys_mmap(8*16) as *i64
15 gs_init_trig(cs, sn)
16
17 let xs: *i64 = sys_mmap(8*16384) as *i64
18 let ys: *i64 = sys_mmap(8*16384) as *i64
19 let cstart: *i64 = sys_mmap(8*2048) as *i64
20 let clen: *i64 = sys_mmap(8*2048) as *i64
21 let np: *i64 = sys_mmap(16) as *i64; np[0]=0
22 let nc: *i64 = sys_mmap(16) as *i64; nc[0]=0
23
24 let phrase: *u8 = "the nishi\x00" as *u8
25 font_text(phrase, 9, xs, ys, cstart, clen, np, nc, cs, sn, 24, 36, 200)
26
27 let cov: *u8 = sys_mmap(W*H)
28 aa_render(xs, ys, cstart, clen, nc[0], cov, W, H, ss)
29
30 let rgb: *u8 = sys_mmap(W*H*3)
31 var i: i64 = 0
32 while i < W*H*3 { rgb[i]=255 as u8; i=i+1 }
33 aa_blit(rgb, W, H, 0, 0, cov, W, H, 22, 30, 52)
34
35 nx_png_write_rgb("_offc/nx_aa_phrase.png\x00" as *u8, rgb, W, H)
36 sys_write(1, "nx_font_test: wrote _offc/nx_aa_phrase.png\n\x00" as *u8, 43)
37 return 0
38}