Displaying orbital node characters in groff ms macros

groffpostscriptunicode

I'm trying to display the characters for ascending and descending orbital nodes (☊ and ☋) in groff, however when I export the document to postscript they simply don't show.

Best Answer

There is quite a bit of work to get unusual characters into a PostScript document with groff. First you need to choose a font that contains the character. Googling for the name and the tag unicode can find for example this site which says that, for example, it is found in font DejaVuSans-Bold, which I happen to have on my system in ttf format.

You need to convert the ttf to the format wanted by groff. I created a directory /tmp/font/devps and in it ran

ttf2pt1 -a -e /usr/share/fonts/dejavu/DejaVuSans-Bold.ttf DejaVuSans-Bold

where ttf2pt1 came from a package of the same name on my system. This created the files DejaVuSans-Bold.afm and DejaVuSans-Bold.pfa. They need more conversion with

afmtodit DejaVuSans-Bold.afm textmap DejaVuSans-Bold

where afmtodit came from package groff-perl. This created file DejaVuSans-Bold which can now be referenced from groff by the command

.ft DejaVuSans-Bold

provided you have told it where to find it by doing

export GROFF_FONT_PATH=/tmp/font

before running groff -Tps. You also need to refer to the character by its unicode value in the input text, eg:

here \[u260A] there

(If your input file is in utf-8 you may be able to have this conversion done for you by adding groff option -K utf-8, which I have not tried). Here's a set of commands that worked for me (you may need to change the origin of the ttf file):

mkdir -p /tmp/font/devps
cd  /tmp/font/devps
ttf2pt1 -a -e /usr/share/fonts/dejavu/DejaVuSans-Bold.ttf DejaVuSans-Bold
afmtodit DejaVuSans-Bold.afm textmap DejaVuSans-Bold
export GROFF_FONT_PATH=/tmp/font
groff -Tps >text.ps <<\!
.ps 20
.vs 24
.ft DejaVuSans-Bold
here \[u260A] there
!
gv text.ps

enter image description here

Related Question