diff --git a/Makefile b/Makefile index 3c10b3e..e724567 100644 --- a/Makefile +++ b/Makefile @@ -5,17 +5,36 @@ pngs: characters.png gm convert -crop 8x8 characters.png +adjoin pngs/%03d.png touch pngs +#PNGS=$(wildcard pngs/*.png) +#SVGS=$(patsubst pngs/%.png, %.svg, $(PNGS)) +# +#%.svg: pngs/%.png | pngs +# echo $@ $< +# +#$(SVGS): %.svg: pngs/%.png | pngs +# echo $@ $< +# touch "$@" + +svgs: narrow-svgs wide-svgs + narrow-svgs: pngs mkdir -p narrow-svgs for i in pngs/???.png ;\ do \ f=$$(basename "$$i") ;\ - gm convert "$$i" -crop 6x8 -filter Point -resize 48x64 -black-threshold 50%% "$$f.bmp" ;\ - potrace "$$f.bmp" -o narrow-svgs/"$${f%%.png}.svg" -i -a 1.01 -s -z black ;\ - rm -f "$$f.bmp" ;\ + ./createsvg.sh "$$i" "narrow-svgs/$${f%%.png}.svg" 6 8 ;\ done touch narrow-svgs +wide-svgs: pngs + mkdir -p wide-svgs + for i in pngs/???.png ;\ + do \ + f=$$(basename "$$i") ;\ + ./createsvg.sh "$$i" "wide-svgs/$${f%%.png}.svg" 8 8 ;\ + done + touch wide-svgs + MSX-Screen0.woff: msx-screen0.sfd MSX-Screen0.ttf: msx-screen0.sfd @@ -23,3 +42,8 @@ MSX-Screen0.ttf: msx-screen0.sfd MSX-Screen1.woff: msx-screen1.sfd MSX-Screen1.ttf: msx-screen1.sfd + +.PHONY: clean + +clean: + rm -rf narrow-svgs wide-svgs pngs diff --git a/createsvg.sh b/createsvg.sh new file mode 100755 index 0000000..e9c08ba --- /dev/null +++ b/createsvg.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +INPUT="$1" +OUTPUT="$2" +CROPWIDTH="$3" +CROPHEIGHT="$4" + +W=$CROPWIDTH +H=$CROPHEIGHT +SW=$((W * 8)) +SH=$((H * 8)) + +BMP="${INPUT}.bmp" +gm convert "$INPUT" -crop ${W}x${H} -filter Point -resize ${SW}x${SH} -black-threshold 50%% "$BMP" +potrace "$BMP" -o "$OUTPUT" -i -a 1.01 -s -z black +rm -f "$BMP" diff --git a/importchars.py b/importchars.py new file mode 100644 index 0000000..36171c6 --- /dev/null +++ b/importchars.py @@ -0,0 +1,19 @@ +import fontforge +import sys +import os + +font = fontforge.font() + +f = open(sys.argv[1]) +for line in f: + codepoint, msxcode = line.strip().split() + codepoint = int(codepoint) + msxcode = int(msxcode) + glyph = font.createChar(codepoint) + svgfile = "{:03d}.svg".format(msxcode) + print("importing", svgfile) + glyph.importOutlines(os.path.join(sys.argv[2], svgfile)) + +font.save(sys.argv[3]) +font.generate(sys.argv[4]) + diff --git a/msx2utf8.py b/msx2utf8.py index fea7455..542f4f3 100755 --- a/msx2utf8.py +++ b/msx2utf8.py @@ -49,6 +49,8 @@ if len(sys.argv) < 2: if sys.argv[1] == '-l': for m,c in msxchars(): + if m < 32 or m == 127: + continue try: n = name(c) except ValueError: