Skip to content

Instantly share code, notes, and snippets.

@jdleslie
Last active November 10, 2017 18:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jdleslie/f94f11b7213cac80bb8e51e57d0705a7 to your computer and use it in GitHub Desktop.
Save jdleslie/f94f11b7213cac80bb8e51e57d0705a7 to your computer and use it in GitHub Desktop.
Convert X11R6 bitmap fonts to Python PIL format
PILFONT ?= pilfont.py
BUILD ?= build
BROKEN ?= broken
FONT_PATH ?= xc/fonts/bdf/75dpi xc/fonts/bdf/misc xc/fonts/bdf/unnec_75dpi
FONT_BDF := $(shell find $(FONT_PATH) -name "*.bdf" -exec basename {} \;)
ifneq ($(wildcard $(BROKEN)),)
FONT_IGNORE := $(shell cat $(BROKEN))
FONT_BDF := $(filter-out $(FONT_IGNORE),$(FONT_BDF))
endif
vpath %.bdf $(FONT_PATH)
# Beware, do not "make clean all", instead "make clean && make all"
.PHONY: all
all: $(FONT_PATH) $(FONT_BDF:%.bdf=$(BUILD)/%.pil)
$(if $(FONT_BDF),,$(MAKE) $@)
xc-2.tar.gz:
wget https://www.x.org/releases/X11R6/$@
$(FONT_PATH): xc-2.tar.gz
tar zxf $<
$(BUILD):
mkdir $(BUILD)
$(BUILD)/%.pil: %.bdf | $(BUILD)
$(PILFONT) $< \
&& mv $(patsubst %.bdf,%.pil,$<) $@ \
|| basename $< >> $(BROKEN)
.PHONY: clean
clean:
rm -rf $(BUILD) $(FONT_IGNORE_PATH) xc*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment