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; -*-
\documentclass{article}
\usepackage[no-math]{fontspec}
\directlua{
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
}}}
\directlua{
fonts.handlers.otf.addfeature {
name = "combos",
type = "multiple",
data = {
["="] = {" ","⠨","⠅"," "},
["X"] = {"⠠","⠭"},
["Y"] = {"⠠","⠽"},
}}}
\setmainfont{DejaVu Sans}[RawFeature=+braille;+combos]
\usepackage{mathastext}
\begin{document}
abc = ABC = XY
$abc\ =\ ABC\ =\ XY$ % should be identical to previous line
\end{document}
Output:
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
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.