code wiki / _hdl_build / nx_font_latinext8.nx
nx_font_latinext8.nx source
↩ module page · 35 lines · 1989 B
1// nx_font_latinext8.nx -- Polish (and general) extended-Latin lowercase glyphs, 8x8, built from the proven
2// nx_font8x8 base letters + a combining accent OR'd into the free rows (lowercase x-height leaves rows 0-1 free
3// above and row 7 free below). Native diacritics so a Pole reads "cześć / dziękuję / miłość" CORRECTLY, not
4// stripped. Covers ł ą ć ę ń ó ś ź ż. Returns an 8-byte glyph or 0 (unsupported). license_tier: ORIGINAL
5import "nx_syscalls.nx"
6import "nx_font8x8.nx"
7
8// copy base ASCII char `ch`'s 8x8 glyph into a fresh 8-byte buffer
9func lx_base(ch: i64) -> *u8 {
10 let t: *u8 = font8x8_table()
11 let g: *u8 = sys_mmap(8)
12 let o: i64 = (ch - 0x20) * 8
13 var i: i64 = 0
14 while i < 8 { g[i] = t[o + i]; i = i + 1 }
15 return g
16}
17func lx_or(g: *u8, row: i64, mask: i64) -> i64 { g[row] = ((g[row] as i64) | mask) as u8; return 0 }
18
19// acute mark (´) above-right, in the free top rows
20func lx_acute(g: *u8) -> i64 { lx_or(g, 0, 0x10); lx_or(g, 1, 0x08); return 0 }
21// ogonek tail (˛) below-right
22func lx_ogonek(g: *u8) -> i64 { lx_or(g, 7, 0x18); return 0 }
23
24func latinext8_glyph(cp: i64) -> *u8 {
25 if cp == 0x142 { let g: *u8 = lx_base(0x6C); lx_or(g, 3, 0x12); return g } // ł (l + bar)
26 if cp == 0x107 { let g: *u8 = lx_base(0x63); lx_acute(g); return g } // ć
27 if cp == 0x15B { let g: *u8 = lx_base(0x73); lx_acute(g); return g } // ś
28 if cp == 0x144 { let g: *u8 = lx_base(0x6E); lx_acute(g); return g } // ń
29 if cp == 0xF3 { let g: *u8 = lx_base(0x6F); lx_acute(g); return g } // ó
30 if cp == 0x17A { let g: *u8 = lx_base(0x7A); lx_acute(g); return g } // ź
31 if cp == 0x17C { let g: *u8 = lx_base(0x7A); lx_or(g, 0, 0x0C); return g } // ż (z + dot)
32 if cp == 0x119 { let g: *u8 = lx_base(0x65); lx_ogonek(g); return g } // ę
33 if cp == 0x105 { let g: *u8 = lx_base(0x61); lx_ogonek(g); return g } // ą
34 return 0 as *u8
35}