Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(font): remove unnecessary lists and duplication in font generation scripts #3713

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 2 additions & 28 deletions dockers/fonts/buildFonts.sh
Original file line number Diff line number Diff line change
@@ -1,29 1,6 @@
#!/usr/bin/env bash
shopt -s extglob

used_fonts=(
KaTeX_AMS-Regular
KaTeX_Caligraphic-Bold
KaTeX_Caligraphic-Regular
KaTeX_Fraktur-Bold
KaTeX_Fraktur-Regular
KaTeX_Main-Regular
KaTeX_Main-Bold
KaTeX_Main-Italic
KaTeX_Main-BoldItalic
KaTeX_Math-Italic
KaTeX_Math-BoldItalic
KaTeX_SansSerif-Bold
KaTeX_SansSerif-Italic
KaTeX_SansSerif-Regular
KaTeX_Script-Regular
KaTeX_Size1-Regular
KaTeX_Size2-Regular
KaTeX_Size3-Regular
KaTeX_Size4-Regular
KaTeX_Typewriter-Regular
)

filetypes=( ttf woff woff2 )

set -e
Expand All @@ -48,7 25,7 @@ if [[ ! -f fonts/Makefile ]]; then
echo "src does not look like katex-fonts" >&2
exit 1
fi
tar cfP "$FILE" ../package.json fonts
tar cfP "$FILE" fonts
popd

# build image if missing
Expand Down Expand Up @@ -76,9 53,6 @@ tar xf fonts.tar
mv fonts temp
mkdir fonts
for filetype in "${filetypes[@]}"; do
for font in "${used_fonts[@]}"; do
echo "$filetype/$font"
mv "temp/$filetype/$font".* ./fonts/
done
mv temp/$filetype/*.$filetype ./fonts/
done
rm -rf temp fonts.tar
101 changes: 38 additions & 63 deletions src/fonts/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 24,26 @@ CUSTOM=custom.cfg

MFTRACE_MODIFIED=lib/mftrace-modified

PFA := \
cmbsy10.pfa \
cmbx10.pfa \
cmbxti10.pfa \
cmex10.pfa \
cmmi10.pfa \
cmmib10.pfa \
cmr10.pfa \
cmss10.pfa \
cmssbx10.pfa \
cmssi10.pfa \
cmsy10.pfa \
cmti10.pfa \
cmtt10.pfa \
msam10.pfa \
msbm10.pfa \
rsfs10.pfa \
eufb10.pfb \
eufm10.pfb

all: config fonts

$(CUSTOM):
Expand All @@ -39,74 59,29 @@ $(CUSTOM).pl: $(CUSTOM)

.PHONY: config
config: $(CUSTOM).pl
mkdir -p pfa

blacker: $(MFTRACE_MODIFIED)
$(MFTRACE_MODIFIED):
$(PERL) -I. makeBlacker 15 # values between 10 and 30 seem best

pfa: $(MFTRACE_MODIFIED)
@echo "cmr10"
$(PYTHON) $(MFTRACE_MODIFIED) --magnification 1000 --simplify cmr10

@echo "cmmi10"
$(PYTHON) $(MFTRACE_MODIFIED) --magnification 1000 --encoding $(TETEXENCODING)/aae443f0.enc --simplify cmmi10

@echo "cmsy10"
$(PYTHON) $(MFTRACE_MODIFIED) --magnification 1000 --encoding $(TETEXENCODING)/10037936.enc --simplify cmsy10

@echo "cmex10"
$(PYTHON) $(MFTRACE_MODIFIED) --magnification 1000 --simplify cmex10

@echo "cmbx10"
$(PYTHON) $(MFTRACE_MODIFIED) --magnification 1000 --simplify cmbx10

@echo "cmbxti10"
$(PYTHON) $(MFTRACE_MODIFIED) --magnification 1000 --simplify cmbxti10

@echo "cmti10"
$(PYTHON) $(MFTRACE_MODIFIED) --magnification 1000 --simplify cmti10

@echo "msam10"
$(PYTHON) $(MFTRACE_MODIFIED) --magnification 1000 --simplify --encoding $(TETEXENCODING)/10037936.enc msam10

@echo "msbm10"
$(PYTHON) $(MFTRACE_MODIFIED) --magnification 1000 --simplify --encoding $(TETEXENCODING)/10037936.enc msbm10

@echo "cmmib10"
$(PYTHON) $(MFTRACE_MODIFIED) --magnification 1000 --encoding $(TETEXENCODING)/aae443f0.enc --simplify cmmib10

@echo "cmbsy10"
$(PYTHON) $(MFTRACE_MODIFIED) --magnification 1000 --encoding $(TETEXENCODING)/10037936.enc --simplify cmbsy10

@echo "cmtt10"
$(PYTHON) $(MFTRACE_MODIFIED) --magnification 1000 --simplify cmtt10

@echo "cmss10"
$(PYTHON) $(MFTRACE_MODIFIED) --magnification 1000 --simplify cmss10
@echo "cmssi10"
$(PYTHON) $(MFTRACE_MODIFIED) --magnification 1000 --simplify cmssi10
@echo "cmssbx10"
$(PYTHON) $(MFTRACE_MODIFIED) --magnification 1000 --simplify cmssbx10

@echo "eufm10"
cp "`$(KPSEWHICH) eufm10.pfb`" eufm10.pfb
@echo "eufb10"
cp "`$(KPSEWHICH) eufb10.pfb`" eufb10.pfb

# echo "eusm10"
# $(PYTHON) $(MFTRACE_MODIFIED) --magnification 1000 --simplify eusm10
# echo "eusb10"
# $(PYTHON) $(MFTRACE_MODIFIED) --magnification 1000 --simplify eusb10

@echo "rsfs10"
$(PYTHON) $(MFTRACE_MODIFIED) --magnification 1000 --simplify --encoding $(BASEENCODING)/tex256.enc rsfs10

mkdir -p pfa
rm -f pfa/*
mv *.pfa pfa
mv *.pfb pfa

ff: pfa
# Create the pfa files
%.pfa: $(MFTRACE_MODIFIED)
$(PYTHON) $(MFTRACE_MODIFIED) --magnification 1000 --simplify $*
mv $@ pfa/$@

# Create the pfb files
%.pfb: $(MFTRACE_MODIFIED)
cp "`$(KPSEWHICH) $@`" pfa/$@

# Create all the FontForge (.ff) scripts to generate the modern .ttf font files
# from the older TeX .pfa and .pfb files. The relation of the .ff and the
# .{pfa, pfb} files is many-to-many, and not one-to-one. Makefile doesn't like
# these types of relations, thus we have a single target that creates all of
# the .ff scripts.
# As a byproduct, the script also creates the initial .ttx files for all the
# different KaTeX fonts.
ff: $(PFA)
mkdir -p ff otf
rm -f ff/* otf/*
$(PERL) -I. makeFF
Expand Down