Groff – Fix Different Font Families Not Working in groff -ms

fontsgroffpostscriptunicode

I'm using groff with ms macros and outputting it to PostScript. On Linux Void. I want to have a different font and also output Unicode characters. I have converted my font as written in this question. As specified, it worked for me (with NO ms macros). Yet it doesn't display a title, an author and headings properly (not at the center, no special formatting).

.ft linlibertine_rah
.TL
Title
.AU
Author
.NH
Heading
.PP
\[u1E6C]

outputs to:

If I compile the same docuemnt with the -ms option, I get a document with 'Times' font and no Unicode symbols (but properly formatted):

enter image description here

It is specified in groff_ms manual that font family is specified with the .FAM string, but result is the same as with .ft. It also outputs to console:

troff: test.ms:9: warning: can't find special character 'u0054_0323'

It definitely has detected the font, as with .ft samplefont it outputs:

troff: test.ms:1: warning: can't find font 'samplefont'
troff: test.ms:9: warning: can't find special character 'u0054_0323'

So my question is: how do I use a different font family in groff with ms macros?

Best Answer

If you want to use the FAM string to specify a font family you will need to use conventional names with the suffixes R B I BI for roman, bold, italic, and bold-italic. In the linked-to example, the font family was DejaVuSans, so you need to provide fonts DejaVuSansR, DejaVuSansB, DejaVuSansI, and DejaVuSansBI. The following worked for me:

mkdir -p /tmp/font/devps
cd  /tmp/font/devps
convert(){ 
  from=${1?} to=${2?}
  ttf2pt1 -a -e "$1" "$2"
  afmtodit "$2".afm textmap "$2"
}
convert /usr/share/fonts/dejavu/DejaVuSans.ttf DejaVuSansR
convert /usr/share/fonts/dejavu/DejaVuSans-Bold.ttf DejaVuSansB
convert /usr/share/fonts/dejavu/DejaVuSans-Oblique.ttf DejaVuSansI
convert /usr/share/fonts/dejavu/DejaVuSans-BoldOblique.ttf DejaVuSansBI
export GROFF_FONT_PATH=/tmp/font
groff -Tps -ms >text.ps <<\!
.ps 20
.vs 24
.ds FAM DejaVuSans
.TL
Title
.AU
Author
.NH
Heading
.PP
roman \[u1E6C]
.B "bold \[u1E6C]
.I "italic \[u1E6C]
.BI "bolditalic \[u1E6C]
!
gv text.ps

enter image description here

Related Question