Rendering Swedish Å Ä and Ö with groff, mupdf

145 Views Asked by At

I am learning to use groff as an alternative to Latex and am struggling with rendering Å Ä and Ö characters.

In an English only setting, I have been running groff with: $ groff -ms example.ms -T pdf > example.pdf
and then viewing my pdf with : $ mupdf example.pdf

I see in the man pages groff_tmac(5) that there is support for Swedish and when I try to extrapolate the example from French in the man pages to Swedish I do not achieve the results I want. I am still getting two strange characters in place of every Å, Ä, or Ö.

I am trying the command $ groff -ms -msv example.ms -T pdf > example.pdf

I have scoured the web both in Swedish and English (Swedish results even worse...seems like no one is using Groff) and am finding zero examples. I don't need the answer, just where someone smarter than myself would start looking. People in my circle just suggest Latex but I am determined to use the much lighter Groff.

I am expecting to have Å Ä and Ö print nicely, so I can do my assignments in groff instead of Latex.

Thank You!

2

There are 2 best solutions below

0
Ljm Dullaart On BEST ANSWER

When I have accented or non-standard-ascii characters in my input text, I run the inputfile through preconv, which solves almost all my problems.

preconv inputfile | groff > outputfile

If you dislike typing the separate preconv, you can also run groff with -k.

If I use the following inputfile:


test
.br
I am expecting to have Å Ä and Ö print nicely,

and run it through preconv, I get

.lf 1 inputfile

test
.br
I am expecting to have \[u00C5] \[u00C4] and \[u00D6] print nicely,

Of course, you can put in the \[u00C4] etc. by hand, but that makes groff a lot less lightweight. And the output of groff then becomes: enter image description here

0
tavo-wasd On

I personally would edit my compiler command to replace with sed the characters I need. I tried preconv but wasn't working for me. Also, sometimes preconv messes up characters at the beginning of a line and it's just not reliable. So, I would use this command to compile my documents:

Note: See list of characters and their unicode code with man groff_char, you'll find Aring, Adieresis and other chars.

sed "s/Å/\\\[u0041_030A\]/g;s/Ä/\\\[u0041_0308\]/g;s/Ö/\\\[u004F_0308\]/g;" file.ms | groff -ms -T pdf

Prettier (just add more sed lines with as many characters with the unicode code found in in man groff_char you want to replace):

sed "
s/Å/\\\[u0041_030A\]/g;
s/Ä/\\\[u0041_0308\]/g;
s/Ö/\\\[u004F_0308\]/g;
" file.ms | groff -ms -T pdf