https://github.com/akkartik/mu/blob/main/apps/ex15.mu
 1 # Demo of combining-character support in Mu, which can be summarized as, "the
 2 # old typewriter-based approach of backing up one character and adding the
 3 # accent or _matra_ in."
 4 #   https://en.wikipedia.org/wiki/Combining_character
 5 #
 6 # Mu uses this approach for both accents in Latin languages and vowel
 7 # diacritics in Abugida scripts.
 8 #   https://en.wikipedia.org/wiki/Diacritic
 9 #   https://en.wikipedia.org/wiki/Abugida
10 #
11 # Steps for trying it out:
12 #   1. Translate this example into a disk image code.img.
13 #       ./translate apps/ex15.mu
14 #   2. Run:
15 #       qemu-system-i386 -hda code.img -hdb data.img
16 #
17 # Expected output: 'à' in green in a few places near the top-left corner of
18 # screen, showing off what this approach can and cannot do.
19 
20 fn main screen: (addr screen), keyboard: (addr keyboard), data-disk: (addr disk) {
21   # at the top of screen, the accent is almost cropped
22   var dummy/eax: int <-    draw-code-point-on-real-screen   0x61/a,                       0/x 0/y, 3/fg 0/bg
23   var dummy/eax: int <- overlay-code-point-on-real-screen 0x0300/combining-grave-accent,  0/x 0/y, 3/fg 0/bg
24 
25   # below a grapheme with a descender, the accent uglily overlaps
26   #   https://en.wikipedia.org/wiki/Descender
27   var dummy/eax: int <-    draw-code-point-on-real-screen   0x67/g,                       4/x 3/y, 3/fg 0/bg
28   var dummy/eax: int <-    draw-code-point-on-real-screen   0x61/a,                       4/x 4/y, 3/fg 0/bg
29   var dummy/eax: int <- overlay-code-point-on-real-screen 0x0300/combining-grave-accent,  4/x 4/y, 3/fg 0/bg
30 
31   # beside a grapheme with a descender, it becomes more obvious that monowidth fonts can't make baselines line up
32   #   https://en.wikipedia.org/wiki/Baseline_(typography)
33   var dummy/eax: int <-    draw-code-point-on-real-screen   0x67/g,                       8/x 3/y, 3/fg 0/bg
34   var dummy/eax: int <-    draw-code-point-on-real-screen   0x61/a,                       9/x 3/y, 3/fg 0/bg
35   var dummy/eax: int <- overlay-code-point-on-real-screen 0x0300/combining-grave-accent,  9/x 3/y, 3/fg 0/bg
36 }