Last active
October 19, 2023 14:02
-
-
Save damieng/d2519cda1c674b4ede74f154f05f2431 to your computer and use it in GitHub Desktop.
ZX Spectrum font publishing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
for i in "$@" | |
do | |
echo | |
echo Publishing ${i} | |
name="${i%.*}" | |
zip="${name}.zip" | |
rm -rf "${zip}" | |
# Folder cleanup | |
mkdir -p Spectrum | |
mkdir -p CPC | |
mkdir -p PC | |
mkdir -p BBC | |
mkdir -p C64 | |
mkdir -p Atari8 | |
mkdir -p CoCo | |
mkdir -p Source | |
mkdir -p Web | |
rm -rf Gameboy | |
mkdir -p GameBoy | |
mv *.fzx Spectrum/ 2> /dev/null | |
# Created by ZX to TTF conversion process | |
mv *.bdf PC/ 2> /dev/null | |
mv *.psf PC/ 2> /dev/null | |
mv *.ttf PC/ 2> /dev/null | |
# Preview creation | |
echo Creating previews | |
for f in *.ch8 ; do pw.exe preview "$f" . ; done | |
optipng -o7 -zm1-9 *.png --quiet | |
# Spectrum creation | |
tap="${name}.tap" | |
echo Creating Spectrum ${tap} | |
cp *.ch8 Spectrum/ | |
cd Spectrum | |
rm -f *.tap | |
for f in *.ch8 ; do blk="${f%.*}" ; bin2tap 49152 "${blk:0:10}" "$f" ; done | |
cat /mnt/d/ZXO/_Templates/Spectrum/Preview.tap *.tap > tap.tmp | |
rm -f *.tap | |
mv tap.tmp "${tap}" | |
cd .. | |
# Source creation | |
cd Source | |
echo Generating Z80 assembler | |
for f in ../*.ch8 ; do pw.exe z80asm "$f" . --credit "from https://damieng.com/zx-origins" >> /dev/null ; done | |
echo Generating 6502 assembler | |
for f in ../*.ch8 ; do pw.exe 6502asm "$f" . --credit "from https://damieng.com/zx-origins" >> /dev/null ; done | |
echo Generating X86 assembler | |
for f in ../*.ch8 ; do pw.exe x86asm "$f" . --credit "from https://damieng.com/zx-origins" >> /dev/null ; done | |
echo Generating 68000 assembler | |
for f in ../*.ch8 ; do pw.exe 68000asm "$f" . --credit "from https://damieng.com/zx-origins" >> /dev/null ; done | |
echo Generating C headers | |
for f in ../*.ch8 ; do pw.exe chead "$f" . --credit "from https://damieng.com/zx-origins" >> /dev/null ; done | |
cd .. | |
# BBC creation | |
ssd="${name}.ssd" | |
echo Creating BBC ${ssd} | |
cd PC | |
for f in *.psf ; do psf2bbc "$f" "../BBC/${f%.*}.bbc"; done | |
cd ../BBC | |
cp /mnt/d/ZXO/_Templates/BBC/filelist.txt filelist.txt | |
unique-names.js . '*.bbc' B. >> filelist.txt | |
unix2dos filelist.txt | |
mkimg.exe Preview-DFS.ssd -fs DFS -t ZXOrigins -opt 3 -pad -i@filelist.txt >> /dev/null | |
cd .. | |
# Amstrad CPC creation | |
echo Creating Amstrad CPC BASIC + Disk | |
rm -f CPC/* | |
for f in *.ch8 ; do pw.exe zxtocpc "$f" CPC --credit "from https://damieng.com/zx-origins" ; done | |
cd CPC | |
unique-renames.js . '*.bas' | |
cp /mnt/d/ZXO/_Templates/Amstrad/CPC.dsk CPC.dsk | |
for f in *.bas ; do iDSK CPC.dsk -i "$f" -t 0 -f ; done | |
cd .. | |
# C64 creation | |
echo Creating C64 binaries | |
for f in *.ch8 ; do pw.exe zxtoc64 "$f" C64 --templatePath d:/ZXO/_Templates ; done | |
# Atari creation | |
echo Creating Atari8 binaries | |
for f in *.ch8 ; do pw.exe zxtoa8 "$f" Atari8 --templatePath d:/ZXO/_Templates ; done | |
# CoCo creation | |
echo Creating CoCo binaries | |
for f in *.ch8 ; do zx2ccv "${f%.*}" ; done | |
mv *.CHR CoCo/ | |
cd CoCo | |
cp /mnt/d/ZXO/_Templates/CoCo/Empty35.dsk "${name}.dsk" | |
for f in *.CHR ; do writecocofile "${name}.dsk" "${f}" ; decb attr -2 -b "${name}.dsk","${f}" >> /dev/null ; done | |
cd .. | |
# Game Boy creation | |
echo Creating Game Boy binaries | |
for f in *.ch8 ; do pw.exe zxtogbs "$f" GameBoy --dark --proportional ; done | |
# Web creation | |
echo Creating web fonts | |
cd Web | |
rm -f *.woff2 | |
cp ../PC/*.ttf . | |
for f in *.ttf ; do fonttools ttLib.woff2 compress "$f" ; done | |
for f in *.ttf ; do ttf2woff "$f" "${f%.*}.woff"; done | |
rm *.ttf | |
cd .. | |
# Clean-up | |
rm -f PC/*.vfb | |
rm -f */filelist.txt | |
# ZIP creation | |
echo Packing $zip | |
rm -rf "${zip}" | |
7z a "${zip}" Spectrum/* BBC/* PC/* Atari8/* C64/* CPC/* GameBoy/* CoCo/* Source/* Web/* *.png /mnt/d/ZXO/README.md | |
# Upload | |
aws s3 cp "${zip}" "s3://[my-bucket-name]/fonts/zx-origins/${zip}" | |
for f in *.png ; do aws s3 cp "$f" s3://damieng-resources/fonts/zx-origins/ ; done | |
aws s3 cp Spectrum s3://[my-bucket-name]/fonts/zx-origins/ch8/ --recursive --exclude "*" --include "*.ch8" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment