#StackBounty: #luatex #fontspec #font-encodings Map all ASCII characters in document to Nemeth Braille

Bounty: 100

My goal is to type regular LaTeX input, and remap the fonts to produce Nemeth Braille. One answer to the question LaTeX to Braille
was to download the font http://www.searchfreefonts.com/free/braille.htm . This doesn’t work for me because this font doesn’t map (by default) ASCII characters the same way as Nemeth Braille. For instance using that font, 0 and 9 become ⠔ and ⠯ instead of ⠴ and ⠔ respectively.
Furthermore, in any case I’d like to be able to map, in some cases, an individual ASCII character to a pair of Braille characters.

I tried using the font handling features of luatex to make substitutions. They didn’t seem to have any effect for the font mentioned in the answer above, but they did for DejaVu.

Here’s what I tried:

% -*- TeX-engine: luatex; -*-

fonts.handlers.otf.addfeature {
    name = "braille",
    type = "substitution", 
    data = {
      ["a"] = "⠁", ["b"] = "⠃", ["c"] = "⠉",
      % etc. all the way to z
      ["A"] = {"⠠","⠁"}, ["B"] = {"⠠","⠃"},
      ["C"] = {"⠠","⠉"}, % etc. all the way to Z

fonts.handlers.otf.addfeature {
    name = "combos",
    type = "multiple", 
    data = {
      ["="] = {" ","⠨","⠅"," "}, 
      ["X"] = {"⠠","⠭"}, 
      ["Y"] = {"⠠","⠽"},

setmainfont{DejaVu Sans}[RawFeature=+braille;+combos]

abc = ABC = XY 

$abc = ABC = XY$  % should be identical to previous line


Output of MWE

What still doesn’t work: (1) The font feature of type substitution doesn’t let me replace one character of input with two characters of output (or I don’t know how to make it do this). So A, B, and C are incorrect in both lines. (2) The font feature of type multiple does allow one input go to two output characters, but it’s not inherited by the math fonts using the mathastext package (or I don’t know how to make it do this). So =, X and Y are incorrect in the math line.

Does anyone know how to get the remapping to work for either DejaVu or the Braille font mentioned above?

Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.