Hello Damian, I've been meaning to use Computer Modern with groff for quite some time. Your message motivated me to find a semi-automated way to do that. Thanks!
Please find attached a Makefile that downloads a specified release (currently 0.7.0) of the Computer Modern Unicode font sources from https://sourceforge.net/projects/cm-unicode/files/ and generates the font files for use with groff along with some helpful font name aliases. I find the original font names are named in a way that makes them hard to use, e.g. what font is provided by cmunst? Whereas their internal font name is much more explicit, e.g. CMUTypewriterOblique.¹ To use the Makefile, place it in a directory you feel comfortable to include in GROFF_FONT_PATH and run: % make download % make fonts # Needs to be two separate commands for now The Makefile requires common command-line utilities like grep, sed, awk etc. to be available and an installation of groff providing afmtodit. > What is the best way to use them? One very good way I found to use the Computer Modern font in my groff documents without needing to worry much about the details of setting the font is using the attached cmu.tmac macro package which substitutes groff's commonly used font styles (R, B, I, C, CI, etc.) with an equivalent from Computer Modern Unicode. To use cmu.tmac, place it in a directory you feel comfortable to include IN GROFF_TMAC_PATH and include the cmu macro package, either via the commandline, i.e. `-mcmu` or from within your document via `.mso cmu.tmac`. As an example the following command produces the documentation for the ms macro package using Computer Modern Unicode: % groff -Tpdf -t -ms -mcmu doc/ms.ms > doc/ms.pdf Hope this helps Alexis ¹ For those wondering: The Makefile deletes hyphens from the font names as groff did not properly show the fonts that contained a hyphen in their name.
# Generate Computer Modern Unicode font files for use with groff # https://cm-unicode.sourceforge.io/ VERSION := 0.7.0 HASH := f7c9209524dfe1dd40e680139645d07b2c34b187a4121ec444909d6429e2c76e URL := https://sourceforge.net/projects/cm-unicode/files/cm-unicode/$(VERSION) FONT_ARCHIVE := cm-unicode-$(VERSION)-pfb.tar.xz CURL := curl CURL_FLAGS := --disable --location --progress-bar AWK := gawk ENV := /usr/bin/env SHASUM := shasum AFMTODIT := afmtodit GROFF ?= $(shell which groff) GROFF_FLAGS := DEVPS_DIR := $(dir $(GROFF))../share/groff/current/font/devps include $(DEVPS_DIR)/generate/Makefile srcdir := $(DEVPS_DIR)/generate afmdir := . cm-unicode-$(VERSION): download download: $(FONT_ARCHIVE) $(FONT_ARCHIVE): @# Download sources $(CURL) $(CURL_FLAGS) --output $@ $(URL)/$@/download @# Verify download echo "$(HASH) $(FONT_ARCHIVE)" | $(SHASUM) -c @# Unpack sources tar Jxf $@ FONTS = $(basename $(notdir $(wildcard cm-unicode-$(VERSION)/*.pfb))) fonts: $(FONTS) @# Create symlinks for groff font files to their font name as these are more self-explanatory grep ^FontName cm-unicode-$(VERSION)/*.afm \ | sed -e 's#.*/##' -e 's#\.afm:FontName##' \ | tr -d - \ | xargs -n2 ln -sf \ # grep sed tr xargs @# Create symlinks for groff font families and font styles ln -sf CMUSerifRoman CMUSerifR ln -sf CMUSerifItalic CMUSerifI ln -sf CMUSerifBold CMUSerifB ln -sf CMUSerifBoldItalic CMUSerifBI ln -sf CMUSansSerif CMUSansSerifR ln -sf CMUSansSerif CMUSansSerifRoman ln -sf CMUSansSerifOblique CMUSansSerifI ln -sf CMUSansSerifOblique CMUSansSerifItalic ln -sf CMUSansSerifBold CMUSansSerifB ln -sf CMUSansSerifBoldOblique CMUSansSerifBI ln -sf CMUSansSerifBoldOblique CMUSansSerifBoldItalic ln -sf CMUTypewriterRegular CMUTypewriterR ln -sf CMUTypewriterItalic CMUTypewriterI ln -sf CMUTypewriterBold CMUTypewriterB ln -sf CMUTypewriterBoldItalic CMUTypewriterBI ln -sf CMUBrightRoman CMUBrightR ln -sf CMUBrightOblique CMUBrightI ln -sf CMUBrightOblique CMUBrightItalic ln -sf CMUBrightBold CMUBrightB ln -sf CMUBrightBoldOblique CMUBrightBI ln -sf CMUBrightBoldOblique CMUBrightBoldItalic ln -sf CMUConcreteRoman CMUConcreteR ln -sf CMUConcreteItalic CMUConcreteI ln -sf CMUConcreteBold CMUConcreteB ln -sf CMUConcreteBoldItalic CMUConcreteBI @# Create convenience symlinks for groff fonts ln -sf CMUClassicalSerifItalic CMUSerifClassicalItalic @# Place groff font symlinks in the respective device directories cp -P CMU* devps/ mv CMU* devpdf/ $(FONTS): | devps devpdf @# Generate groff font files and symlink to them in the respective device directories cd cm-unicode-$(VERSION); \ $(AFMTODIT) -s $(EFLAG) $(RFLAG) $@.afm $(TEXTMAP) $@; \ ln -sf ../cm-unicode-$(VERSION)/$@ ../devpdf; ln -sf ../cm-unicode-$(VERSION)/$@ ../devps @# Generate download files for generated groff fonts $(AWK) \ -vdir=../cm-unicode-$(VERSION)/ \ '/^name/{pf="$@.pfb"} /^internalname/{i=$$2} END{print i "\t" dir pf}' devps/$@ \ | tee -a devps/download \ | sed -e 's/^/\t/' >> devpdf/download devps devpdf: mkdir -p $@
.\" Replace groff's commonly used font styles with Computer Modern Unicode .fp 1 CMUSerifR . .ftr R CMUSerifR .ftr I CMUSerifI .ftr B CMUSerifB .ftr BI CMUSerifBI . .ftr HR CMUSansSerifR .ftr HI CMUSansSerifI .ftr HB CMUSansSerifB .ftr HBI CMUSansSerifBI . .ftr CR CMUTypewriterR .ftr CI CMUTypewriterI .ftr CB CMUTypewriterB .ftr CBI CMUTypewriterBI . .nx