Working on fully automating the fontforge interaction
This commit is contained in:
parent
e618ef401f
commit
0ea692c54a
4 changed files with 64 additions and 3 deletions
30
Makefile
30
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
|
||||
|
|
16
createsvg.sh
Executable file
16
createsvg.sh
Executable file
|
@ -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"
|
19
importchars.py
Normal file
19
importchars.py
Normal file
|
@ -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])
|
||||
|
|
@ -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:
|
||||
|
|
Loading…
Reference in a new issue