diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2021-09-01 12:46:25 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2021-09-01 12:46:25 -0700 |
commit | d2f96cb0b6c5f05f36122088d7daa546c283fd9a (patch) | |
tree | a5decb34672729c0e096b06d2188983a7263c196 /apps | |
parent | dca845877ba2832144819e136ae7c3a0348ccda3 (diff) | |
download | mu-d2f96cb0b6c5f05f36122088d7daa546c283fd9a.tar.gz |
rendering code-points with combining characters
There's a new example app showing this ability. Still to go: support for combining characters when rendering text and streams.
Diffstat (limited to 'apps')
-rw-r--r-- | apps/ex14.mu | 9 | ||||
-rw-r--r-- | apps/ex15.mu | 36 |
2 files changed, 38 insertions, 7 deletions
diff --git a/apps/ex14.mu b/apps/ex14.mu index 4a2d5dd7..b940e4f6 100644 --- a/apps/ex14.mu +++ b/apps/ex14.mu @@ -1,7 +1,7 @@ # Unicode demo # -# Mu can't read Unicode from keyboard yet, so we'll read from disk and print -# to screen. +# Mu can't read Unicode from keyboard yet, so we'll read utf-8 from disk and +# print to screen. # # Steps for trying it out: # 1. Translate this example into a disk image code.img. @@ -13,11 +13,6 @@ # qemu-system-i386 -hda code.img -hdb data.img # # Expected output: 'நட' in green near the top-left corner of screen -# -# Limitations: -# - Utf-8 is the one true encoding. -# - No keyboard support yet. -# - Just single-code-point graphemes so far. No combiner characters, etc. fn main screen: (addr screen), keyboard: (addr keyboard), data-disk: (addr disk) { var text-storage: (stream byte 0x200) diff --git a/apps/ex15.mu b/apps/ex15.mu new file mode 100644 index 00000000..2d1c6bcf --- /dev/null +++ b/apps/ex15.mu @@ -0,0 +1,36 @@ +# Demo of combining-character support in Mu, which can be summarized as, "the +# old typewriter-based approach of backing up one character and adding the +# accent or _matra_ in." +# https://en.wikipedia.org/wiki/Combining_character +# +# Mu uses this approach for both accents in Latin languages and vowel +# diacritics in Abugida scripts. +# https://en.wikipedia.org/wiki/Diacritic +# https://en.wikipedia.org/wiki/Abugida +# +# Steps for trying it out: +# 1. Translate this example into a disk image code.img. +# ./translate apps/ex15.mu +# 2. Run: +# qemu-system-i386 -hda code.img -hdb data.img +# +# Expected output: 'à' in green in a few places near the top-left corner of +# screen, showing off what this approach can and cannot do. + +fn main screen: (addr screen), keyboard: (addr keyboard), data-disk: (addr disk) { + # at the top of screen, the accent is almost cropped + var dummy/eax: int <- draw-code-point-on-real-screen 0x61/a, 0/x 0/y, 3/fg 0/bg + var dummy/eax: int <- overlay-code-point-on-real-screen 0x0300/combining-grave-accent, 0/x 0/y, 3/fg 0/bg + + # below a grapheme with a descender, the accent uglily overlaps + # https://en.wikipedia.org/wiki/Descender + var dummy/eax: int <- draw-code-point-on-real-screen 0x67/g, 4/x 3/y, 3/fg 0/bg + var dummy/eax: int <- draw-code-point-on-real-screen 0x61/a, 4/x 4/y, 3/fg 0/bg + var dummy/eax: int <- overlay-code-point-on-real-screen 0x0300/combining-grave-accent, 4/x 4/y, 3/fg 0/bg + + # beside a grapheme with a descender, it becomes more obvious that monowidth fonts can't make baselines line up + # https://en.wikipedia.org/wiki/Baseline_(typography) + var dummy/eax: int <- draw-code-point-on-real-screen 0x67/g, 8/x 3/y, 3/fg 0/bg + var dummy/eax: int <- draw-code-point-on-real-screen 0x61/a, 9/x 3/y, 3/fg 0/bg + var dummy/eax: int <- overlay-code-point-on-real-screen 0x0300/combining-grave-accent, 9/x 3/y, 3/fg 0/bg +} |