-1

I would like to write in arbitrary fonts in the terminal, such as Chinese, Devangari, Mayan Hieroglyphs (a font that is not even part of unicode yet), etc.

I would like to press "a" to get ऄ, etc., basically I say "enter encoding DEVANAGARI" and now "a" is ऄ, etc. Or I say "enter encoding MAYAN" and "a" is some "private unicode space" glyph, etc. How can I do this? Can I set it dynamically somehow, maybe using Swift (for Mac) if I had a Mac app running in the background?

For example, I would imagine like this:

$ change-script DEVANAGARI
$ a
# replaced with
$ ऄ
# etc

How can I do this in the Terminal app, or in any app for that matter?

This way I can use the ASCII keyboard to write in arbitrary fonts even if they aren't in unicode.

Lance
  • 75,200
  • 93
  • 289
  • 503
  • A font is only used to render a glyph, what you want is to remap your keyboard so that it uses a different set of glyphs. Search for this instead, and from macOs, you can go to System Preferences > Keyboard > Input Sources > [ + ] from there you'll be able to set a few different keyboard layout and you can even use [custom ones](https://beebom.com/how-modify-or-create-custom-keyboard-layouts-mac/). But your question is off-topic for SO... – Kaiido Jan 22 '20 at 04:36
  • My question is, how do I programmatically do this? – Lance Jan 22 '20 at 04:48

1 Answers1

1

Answering the title question: yes. This can be accomplished by changing the active keyboard. Apple supplies a bunch (including many QWERTY-style for various scripts that roughly map the English/latin letters to (rough) equivalents in the script). As noted in a comment, there are tools available to create custom layouts if the supplied ones are not sufficient.

As to the question of doing it programatically, that's trickier. The accepted answer to this (old) SO question suggests that you can programatically switch keyboards (presumably: installed ones).

But by a close read of your question and follow-up, it seems like you basically want to create/modify the active keyboard dynamically (?). I'd be surprised if anything like that is supported, but I'm also not sure why it would be necessary to do that if you have the ability to switch programatically.

djangodude
  • 5,362
  • 3
  • 27
  • 39