A way to enter sitelen pona (toki pona) glyphs in emacs.
For now, the result is an input method that inputs sitelen pona unicode glyphs as you type ASCII characters. There are many improvements to be made.
This allows you to toggle between writing your default language and sitelen pona, without futzing with fonts or modes. And your principal/configured fonts remain unchanged for all but the relevant glyphs.
Read on for stepwise instruction. If you just want the input method then look at toki-pona.el
. In short:
- Install the font
- Map unicode blocks
- Define and use the input method
I have only tested this with Fairfax Pona HD. The website gives a good account of the font's features, not all of which will work just now. The rest of these instructions are emacs-specific, so install the font on your system and let's go already.
Enable unicode fonts. For instance, if you use use-package
then you can add this line in init.el
:
(use-package unicode-fonts)
sitelen pona does not have its own unicode block. For more on that story, see sona.pona.la. By convention, sitelen pona glyphs map onto specific code points in two so called Private Use Areas. So we need to tell emacs to use unicode characters from Fairfax Pona HD (only) when it needs to enter a character whose code point is in one of those two ranges. For instance, add to init.el
:
(set-fontset-font t '(#xe000 . #xf8ff) "Fairfax Pona HD")
(set-fontset-font t '(#xf0000 . #x10ffff) "Fairfax Pona HD")
A handy visualisation of the glyph to unicode code point mappings is on this lipu-sona.pona.la gif.
If you've evaled those lines then trying to enter a code point from that table into any buffer should show a sitelen pona glyph. For instance C-x 8 RET F1932 RET and be rewarded with the glyph for .
Eval toki-pona.el
to load the emacs quail input rules that enter sitelen pona when you type ASCII characters. For instance, to load it when emacs starts, clone the git repo and load it from init.el
:
(load "~/PATH-TO-GIT-REPO/toki-pona.el")
toki-pona.el
also defines a function my/quailify
that I used to derive the many ASCII->unicode rule mappings from the Opentype font feature (.fea
) file.
C-\ (toggle-input-method
) and select toki pona
. I've only tested this with an english keyboard layout. Repeat to toggle back.
ASCII to sitelen pona mappings are like those describes in Fairfax Pona HD features, with some additions:
- single space ends current glyph entry (if necessary)
- double space is mapped to a single space character
- underscore _ places the preceding glyph between horizontal cartouche lines
- Pi starts extended pi
- all ASCII transliterations work; see the font features or the quail rules in
toki-pona.el
for fun like:
This is based on a discouraged method described by Fairfax fonts' creators, after I failed to get Opentype features working automatically in emacs. A possibly related issue is discussed here on stackexchange.
In support of future goals, I looked at treating extended glyphs as syntactical enclosures, so for instance having cartouches behave like parens. The first step is modifying the syntax table:
(modify-syntax-entry ? "(")
(modify-syntax-entry ? ")")
Then it was easy to have cartouche lines added automatically while typing after an opening cartouche 'bracket' (see the elisp for functions and the relevant hook). Thinking about how this would work for extended Pi puts me in mind of the chars whose function I couldn't guess in the rule assignments---perhaps there are some extended glyph terminators there.
- Control char manual input for other extended glyphs (a la cartouche, extended pi)
- toki pona ?minor-mode
- Properly format extended glyphs and inners (?ligatures)
- Identify unidentified characters, i.e. are some of them extended glyph terminators?
- Cartouches as parens (partial progress using syntax table)
- Automatically reformat glyphs contained in cartouche/long pi etc. (?redundant w ligatures)
- Properly format extended glyphs and inners (?ligatures)
- Glyph completion
- ?Dictionary
- Font Lock
- Unicode character description strings (e.g. currently no completion for UCSUR
insert-char
) - Additional abbreviated input methods
This is almost entirely based on resources in Fairfax HD etc. fonts, and the existing emacs quail input method.
Thank you for reading!