Skip to content

Entry method for sitelen pona (toki pona) in emacs

Notifications You must be signed in to change notification settings

fustygerbil/sitelen-el

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 

Repository files navigation

sitelen-el

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.

Setup

Read on for stepwise instruction. If you just want the input method then look at toki-pona.el. In short:

  1. Install the font
  2. Map unicode blocks
  3. Define and use the input method

1: Install the font

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.

2: Map unicode blocks

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 mani.

3: Define the input method

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.

Usage

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)
    • so e suno gives e suno, and esun o esun o
  • double space is mapped to a single space character
  • underscore _ places the preceding glyph between horizontal cartouche lines
    • square brackets enclose the cartouche
    • [jan_pona_] jan pona in a cartouche
  • Pi starts extended pi
    • comma , places preceding glyph onto Pi extension line
    • tomo Pi telo,nasa, tomo pi telo nasa with extended pi
  • all ASCII transliterations work; see the font features or the quail rules in toki-pona.el for fun like:
    • kijtesantakalu kijetesantakalu
    • combined glyphs with all joiners
      • zero-width kala-lili kala lili with zero-width joiner
      • stacked kala^lili kala lili with stacked joiner
      • scale kala*lili kala lili with scale joiner

Background

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.

TODO

  • 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)
  • Glyph completion
    • ?Dictionary
  • Font Lock
  • Unicode character description strings (e.g. currently no completion for UCSUR insert-char)
  • Additional abbreviated input methods

Credit

This is almost entirely based on resources in Fairfax HD etc. fonts, and the existing emacs quail input method.

Thank you for reading!

About

Entry method for sitelen pona (toki pona) in emacs

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published