# 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 $@