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?

Update If I add to the MWE above (plus quite a few more substitutions) I get this:

And now we can conclude that
\int_0^\infty e^{-x^2}\,dx = \sqrt{\pi}/2
Here it is with better Nemeth
\int_0^\infty\baseline e^{-x^^2}\baseline \,dx \eq \sqrt{\pi}/2

and here is the output

Longer sample Nemeth code

The first version of the equation is unmodified LaTeX code, but with all the substitutions and commands translated. I think it's not a bad start.

The second one requires the author to make a few changes: indicating when a subscript/superscript is over, and indicating when there's a double superscript, and I used a command for the equals sign (because, as mentioned above, I couldn't get the combination substitution to work). My guess is that more of the latex code could be automated, requiring fewer changes by the author (especially with Luatex?). But it's still not horrible to imagine adding the extra markup to make the Nemeth more accurate.

  • Can we assume that the font will only be used in math mode? – Marcel Krüger Jul 24 '19 at 22:15
  • 1
    I don't think it is that simple to convert LaTeX math to Nemeth. See the article by Susan Jolly in the recent TugBoat. She wrote MathML to Nemeth convertor in Java, but I haven't tried it yet. – michal.h21 Jul 24 '19 at 22:20
  • The font will be used in both main text and math. – Ethan Duckworth Jul 25 '19 at 10:30
  • True, it's not that simple. But the first step, for me, would be to map all the ASCII characters. After that, the basic macros are quite easy. With that, an author could do basic math if they are willing to add/change their markup. Things like tables and matrices would be harder. In any case, at present, I have something that works up to a point, and what's not working is mapping single ASCII characters to pairs of Braille, and someone who knows fonts and/or Luatex probably knows what I could change. – Ethan Duckworth Jul 25 '19 at 10:38
  • multiple substituations don't work with the mode=base used in math. But beside this I'm not convinced that the general idea is sound. Imho you will run into problems as soon as \int, or \frac or limits/superscripts etc are involved. – Ulrike Fischer Jul 29 '19 at 10:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.