At 2025-01-20T18:15:48+0100, Francesco Ariis wrote: > Hello groff users, > > how to convert .tff fonts to something usable by `groff`, without > sudo access?
In groff 1.23.0, both the grops(1) and gropdf(1) man pages document a procedure for doing this. It is admittedly more tedious than using Peter Schaffter's convenient script. The latter has doubtless prevented many people from deserting groff in frustration. > I am learning groff and I feel thee need to use a fonts with more > glyphs than what standard fonts offer (e.g.: ◇ U+25C7, ❦ U+2766, etc.) I have a brief aside for PDF users, but not ones with this exact problem. See the footnote.[1] > I came around the excellent `install-font.sh` [1]. It seems to work > when I have root access (it wrote files to /usr/share/groff/), but to > I prefer to stay as user to experiment with options, different styles > of fonts etc. > > My idea is to have a local ./font/ folder and then include it in my > groff invocation (I should do it via `-F`, right?). You can either pass `-F` options to the formatter _and_ the output driver (grops or gropdf), or set the GROFF_FONT_PATH environment variable. The latter is probably easier. > I am not sure how to invoke ./install-font.sh without `su` or `sudo` > though. I don't know, either. But I know what "text.enc" is. > It complains about missing `text.enc`. It's documented. grops(1): /usr/share/groff/1.23.0/font/devps/text.enc describes the encoding scheme used by most PostScript Type 1 fonts; the encoding directive of font description files for the ps device refers to it. If that file is where GNU troff(1) and grops(1) (or gropdf(1)) are told to look for it, they should find it. One of the necessary stages in the process is to run afmtodit(1). A minor convenience added to that program for the forthcoming groff 1.24.0 release is that it records how it was invoked in the comment header that it writes to the font description file. For example, here's the "U-TR" (Times Roman from the URW foundry) font description file generated when building groff from Git. $ head -n 5 build/font/devpdf/U-TR # generated by GNU afmtodit (groff) version 1.23.0 # AFM file: /usr/share/fonts/type1/gsfonts/n021003l.afm # map file: map/text.map # with options "-c -d DESC -e enc/text.enc -i 0 -m" # With that information it is easy to reconstruct the afmtodit command line. If your font is conventional, those same options may work for your font as-is. (I use FreeMono with xterm(1) myself.) > Here is a log of what I see in the terminal: > > f@x270:~/spool/groff/prova/cv/install-font$ ./install-font.sh -P out/ > FreeSerif.ttf [snip] > Leave blank to set name to 'FreeSerif': > =>FreeSerif assigned groff fontname 'FreeSerif'. > 'text.enc' not found. Aborting. I'm afraid I'm unable to usefully support "install-font.sh" itself (writing an alternative for non-interactive use by distribution packages' maintainer scripts is on my long to-do list), but I feel like the foregoing should be enough information to advance you toward a solution. All the way, I hope. Regards, Branden [1] I thought briefly that maybe "just using the URW fonts" would be a good enough solution. But they lack the "WHITE DIAMOND" U+25C7 code point, at least in the versions available to me. Nevertheless, it is sometimes the case that the URW fonts solve code point coverage problems that the Adobe-compatible default fonts don't. However in this case, both Adobe and URW have the "FLORAL HEART" U+2766 and both lack U+25C7. Nevertheless it seems like not a bad time to remind people of the availability of the URW fonts in groff. $ cat EXPERIMENTS/funny-symbols.groff .nf U+25C7 is \[u25C7] U+2766 is \[u2766] # Use Adobe-compatible default foundry. $ groff -T pdf EXPERIMENTS/funny-symbols.groff >| EXPERIMENTS/missing-funny-symbols.pdf troff:EXPERIMENTS/funny-symbols.groff:2: warning: special character 'u25C7' not defined # Use URW foundry. $ groff -T pdf -P -y -P U EXPERIMENTS/funny-symbols.groff >| EXPERIMENTS/funny-symbols.pdf troff:EXPERIMENTS/funny-symbols.groff:2: warning: special character 'u25C7' not defined In _this_ case, the output doesn't differ (apart from any cosmetic distinctions between these metrically-compatible faces), but that won't always be the case. Hence why I evicted this observation into a footnote.
signature.asc
Description: PGP signature