Skip to content
This repository has been archived by the owner on Apr 6, 2021. It is now read-only.

Commit

Permalink
Improve fonts generation: clean up font build scripts (#56)
Browse files Browse the repository at this point in the history
* Remove Main-Regular dependency on Size4

* Clean up font build script

* Normalize whitespaces

* Change ff file name to include -Regular

* Remove Math-Regular font

* Move src/fonts/OTF/TeX to src/fonts

* Use SOURCE_DATE_EPOCH in CircleCI

* Update fonts and metrics

* Update fonts

* Remove redundant extra

* Fix merge conflict

* Update fonts
  • Loading branch information
ylemkimon committed Dec 6, 2019
1 parent c14508c commit 7deb3fd
Show file tree
Hide file tree
Showing 75 changed files with 53 additions and 224 deletions.
9 changes: 5 additions & 4 deletions .circleci/config.yml
Expand Up @@ -10,15 +10,16 @@ jobs:
- run:
name: Build fonts
command: |
SOURCE_DATE_EPOCH=$(git log -1 --format=%ct -- src/fonts)
cd src
cp default.cfg custom.cfg
make custom.cfg.pl
make -C fonts/OTF/TeX fonts
make -C fonts/ fonts
cd ..
rm -f fonts/*.*
cp src/fonts/OTF/TeX/ttf/*.ttf fonts
cp src/fonts/OTF/TeX/woff/*.woff fonts
cp src/fonts/OTF/TeX/woff2/*.woff2 fonts
cp src/fonts/ttf/*.ttf fonts
cp src/fonts/woff/*.woff fonts
cp src/fonts/woff2/*.woff2 fonts
tar zcf fonts.tar.gz fonts
- run:
Expand Down
15 changes: 7 additions & 8 deletions buildFonts.sh
Expand Up @@ -24,7 +24,6 @@ used_fonts=(
KaTeX_Main-Bold
KaTeX_Main-Italic
KaTeX_Main-BoldItalic
KaTeX_Math-Regular
KaTeX_Math-Italic
KaTeX_Math-BoldItalic
KaTeX_SansSerif-Bold
Expand Down Expand Up @@ -59,11 +58,11 @@ IMAGE="katex/fonts:DF-$(openssl sha1 Dockerfile | tail -c 9)"
TMPFILE="$(mktemp "${TMPDIR:-/tmp}/mjf.XXXXXXXX")"
FILE="$TMPFILE"
pushd "src"
if [[ ! -f fonts/OTF/TeX/Makefile ]]; then
echo "src does not look like MathJax-dev" >&2
if [[ ! -f fonts/Makefile ]]; then
echo "src does not look like katex-fonts" >&2
exit 1
fi
tar cf "$FILE" ../package.json Makefile default.cfg fonts/OTF/TeX
tar cfP "$FILE" ../package.json Makefile default.cfg fonts
popd

# build image if missing
Expand All @@ -74,11 +73,11 @@ fi

CMDS="set -ex
export SOURCE_DATE_EPOCH=${LAST_COMMIT_DATE}
tar xf MathJax-dev.tar.gz
tar xfP MathJax-dev.tar.gz
cp default.cfg custom.cfg
make custom.cfg.pl
make -C fonts/OTF/TeX fonts
tar cf /fonts.tar ${filetypes[*]/#/fonts/OTF/TeX/}"
make -C fonts fonts
tar cf /fonts.tar ${filetypes[*]/#/fonts/}"

echo "Creating and starting docker container from image $IMAGE"
CONTAINER=$(docker create "$IMAGE" /bin/sh -c "${CMDS}")
Expand All @@ -96,7 +95,7 @@ mkdir fonts
for filetype in "${filetypes[@]}"; do
for font in "${used_fonts[@]}"; do
echo "$filetype/$font"
mv "temp/OTF/TeX/$filetype/$font".* ./fonts/
mv "temp/$filetype/$font".* ./fonts/
done
done
rm -rf temp fonts.tar
95 changes: 0 additions & 95 deletions fontMetricsData.js
Expand Up @@ -1362,101 +1362,6 @@ export default {
"1009": [0.19444, 0.43056, 0, 0.08334, 0.51702],
"1013": [0, 0.43056, 0, 0.05556, 0.4059],
},
"Math-Regular": {
"65": [0, 0.68333, 0, 0.13889, 0.75],
"66": [0, 0.68333, 0.05017, 0.08334, 0.75851],
"67": [0, 0.68333, 0.07153, 0.08334, 0.71472],
"68": [0, 0.68333, 0.02778, 0.05556, 0.82792],
"69": [0, 0.68333, 0.05764, 0.08334, 0.7382],
"70": [0, 0.68333, 0.13889, 0.08334, 0.64306],
"71": [0, 0.68333, 0, 0.08334, 0.78625],
"72": [0, 0.68333, 0.08125, 0.05556, 0.83125],
"73": [0, 0.68333, 0.07847, 0.11111, 0.43958],
"74": [0, 0.68333, 0.09618, 0.16667, 0.55451],
"75": [0, 0.68333, 0.07153, 0.05556, 0.84931],
"76": [0, 0.68333, 0, 0.02778, 0.68056],
"77": [0, 0.68333, 0.10903, 0.08334, 0.97014],
"78": [0, 0.68333, 0.10903, 0.08334, 0.80347],
"79": [0, 0.68333, 0.02778, 0.08334, 0.76278],
"80": [0, 0.68333, 0.13889, 0.08334, 0.64201],
"81": [0.19444, 0.68333, 0, 0.08334, 0.79056],
"82": [0, 0.68333, 0.00773, 0.08334, 0.75929],
"83": [0, 0.68333, 0.05764, 0.08334, 0.6132],
"84": [0, 0.68333, 0.13889, 0.08334, 0.58438],
"85": [0, 0.68333, 0.10903, 0.02778, 0.68278],
"86": [0, 0.68333, 0.22222, 0, 0.58333],
"87": [0, 0.68333, 0.13889, 0, 0.94445],
"88": [0, 0.68333, 0.07847, 0.08334, 0.82847],
"89": [0, 0.68333, 0.22222, 0, 0.58056],
"90": [0, 0.68333, 0.07153, 0.08334, 0.68264],
"97": [0, 0.43056, 0, 0, 0.52859],
"98": [0, 0.69444, 0, 0, 0.42917],
"99": [0, 0.43056, 0, 0.05556, 0.43276],
"100": [0, 0.69444, 0, 0.16667, 0.52049],
"101": [0, 0.43056, 0, 0.05556, 0.46563],
"102": [0.19444, 0.69444, 0.10764, 0.16667, 0.48959],
"103": [0.19444, 0.43056, 0.03588, 0.02778, 0.47697],
"104": [0, 0.69444, 0, 0, 0.57616],
"105": [0, 0.65952, 0, 0, 0.34451],
"106": [0.19444, 0.65952, 0.05724, 0, 0.41181],
"107": [0, 0.69444, 0.03148, 0, 0.5206],
"108": [0, 0.69444, 0.01968, 0.08334, 0.29838],
"109": [0, 0.43056, 0, 0, 0.87801],
"110": [0, 0.43056, 0, 0, 0.60023],
"111": [0, 0.43056, 0, 0.05556, 0.48472],
"112": [0.19444, 0.43056, 0, 0.08334, 0.50313],
"113": [0.19444, 0.43056, 0.03588, 0.08334, 0.44641],
"114": [0, 0.43056, 0.02778, 0.05556, 0.45116],
"115": [0, 0.43056, 0, 0.05556, 0.46875],
"116": [0, 0.61508, 0, 0.08334, 0.36111],
"117": [0, 0.43056, 0, 0.02778, 0.57246],
"118": [0, 0.43056, 0.03588, 0.02778, 0.48472],
"119": [0, 0.43056, 0.02691, 0.08334, 0.71592],
"120": [0, 0.43056, 0, 0.02778, 0.57153],
"121": [0.19444, 0.43056, 0.03588, 0.05556, 0.49028],
"122": [0, 0.43056, 0.04398, 0.05556, 0.46505],
"915": [0, 0.68333, 0.13889, 0.08334, 0.61528],
"916": [0, 0.68333, 0, 0.16667, 0.83334],
"920": [0, 0.68333, 0.02778, 0.08334, 0.76278],
"923": [0, 0.68333, 0, 0.16667, 0.69445],
"926": [0, 0.68333, 0.07569, 0.08334, 0.74236],
"928": [0, 0.68333, 0.08125, 0.05556, 0.83125],
"931": [0, 0.68333, 0.05764, 0.08334, 0.77986],
"933": [0, 0.68333, 0.13889, 0.05556, 0.58333],
"934": [0, 0.68333, 0, 0.08334, 0.66667],
"936": [0, 0.68333, 0.11, 0.05556, 0.61222],
"937": [0, 0.68333, 0.05017, 0.08334, 0.7724],
"945": [0, 0.43056, 0.0037, 0.02778, 0.6397],
"946": [0.19444, 0.69444, 0.05278, 0.08334, 0.56563],
"947": [0.19444, 0.43056, 0.05556, 0, 0.51773],
"948": [0, 0.69444, 0.03785, 0.05556, 0.44444],
"949": [0, 0.43056, 0, 0.08334, 0.46632],
"950": [0.19444, 0.69444, 0.07378, 0.08334, 0.4375],
"951": [0.19444, 0.43056, 0.03588, 0.05556, 0.49653],
"952": [0, 0.69444, 0.02778, 0.08334, 0.46944],
"953": [0, 0.43056, 0, 0.05556, 0.35394],
"954": [0, 0.43056, 0, 0, 0.57616],
"955": [0, 0.69444, 0, 0, 0.58334],
"956": [0.19444, 0.43056, 0, 0.02778, 0.60255],
"957": [0, 0.43056, 0.06366, 0.02778, 0.49398],
"958": [0.19444, 0.69444, 0.04601, 0.11111, 0.4375],
"959": [0, 0.43056, 0, 0.05556, 0.48472],
"960": [0, 0.43056, 0.03588, 0, 0.57003],
"961": [0.19444, 0.43056, 0, 0.08334, 0.51702],
"962": [0.09722, 0.43056, 0.07986, 0.08334, 0.36285],
"963": [0, 0.43056, 0.03588, 0, 0.57141],
"964": [0, 0.43056, 0.1132, 0.02778, 0.43715],
"965": [0, 0.43056, 0.03588, 0.02778, 0.54028],
"966": [0.19444, 0.43056, 0, 0.08334, 0.65417],
"967": [0.19444, 0.43056, 0, 0.05556, 0.62569],
"968": [0.19444, 0.69444, 0.03588, 0.11111, 0.65139],
"969": [0, 0.43056, 0.03588, 0, 0.62245],
"977": [0, 0.69444, 0, 0.08334, 0.59144],
"981": [0.19444, 0.69444, 0, 0.08334, 0.59583],
"982": [0, 0.43056, 0.02778, 0, 0.82813],
"1009": [0.19444, 0.43056, 0, 0.08334, 0.51702],
"1013": [0, 0.43056, 0, 0.05556, 0.4059],
},
"SansSerif-Bold": {
"33": [0, 0.69444, 0, 0, 0.36667],
"34": [0, 0.69444, 0, 0, 0.55834],
Expand Down
Binary file modified fonts/KaTeX_AMS-Regular.ttf
Binary file not shown.
Binary file modified fonts/KaTeX_AMS-Regular.woff
Binary file not shown.
Binary file modified fonts/KaTeX_AMS-Regular.woff2
Binary file not shown.
Binary file modified fonts/KaTeX_Caligraphic-Bold.ttf
Binary file not shown.
Binary file modified fonts/KaTeX_Caligraphic-Bold.woff
Binary file not shown.
Binary file modified fonts/KaTeX_Caligraphic-Bold.woff2
Binary file not shown.
Binary file modified fonts/KaTeX_Caligraphic-Regular.ttf
Binary file not shown.
Binary file modified fonts/KaTeX_Caligraphic-Regular.woff
Binary file not shown.
Binary file modified fonts/KaTeX_Caligraphic-Regular.woff2
Binary file not shown.
Binary file modified fonts/KaTeX_Fraktur-Bold.ttf
Binary file not shown.
Binary file modified fonts/KaTeX_Fraktur-Bold.woff
Binary file not shown.
Binary file modified fonts/KaTeX_Fraktur-Bold.woff2
Binary file not shown.
Binary file modified fonts/KaTeX_Fraktur-Regular.ttf
Binary file not shown.
Binary file modified fonts/KaTeX_Fraktur-Regular.woff
Binary file not shown.
Binary file modified fonts/KaTeX_Fraktur-Regular.woff2
Binary file not shown.
Binary file modified fonts/KaTeX_Main-Bold.ttf
Binary file not shown.
Binary file modified fonts/KaTeX_Main-Bold.woff
Binary file not shown.
Binary file modified fonts/KaTeX_Main-Bold.woff2
Binary file not shown.
Binary file modified fonts/KaTeX_Main-BoldItalic.ttf
Binary file not shown.
Binary file modified fonts/KaTeX_Main-BoldItalic.woff
Binary file not shown.
Binary file modified fonts/KaTeX_Main-BoldItalic.woff2
Binary file not shown.
Binary file modified fonts/KaTeX_Main-Italic.ttf
Binary file not shown.
Binary file modified fonts/KaTeX_Main-Italic.woff
Binary file not shown.
Binary file modified fonts/KaTeX_Main-Italic.woff2
Binary file not shown.
Binary file modified fonts/KaTeX_Main-Regular.ttf
Binary file not shown.
Binary file modified fonts/KaTeX_Main-Regular.woff
Binary file not shown.
Binary file modified fonts/KaTeX_Main-Regular.woff2
Binary file not shown.
Binary file modified fonts/KaTeX_Math-BoldItalic.ttf
Binary file not shown.
Binary file modified fonts/KaTeX_Math-BoldItalic.woff
Binary file not shown.
Binary file modified fonts/KaTeX_Math-BoldItalic.woff2
Binary file not shown.
Binary file modified fonts/KaTeX_Math-Italic.ttf
Binary file not shown.
Binary file modified fonts/KaTeX_Math-Italic.woff
Binary file not shown.
Binary file modified fonts/KaTeX_Math-Italic.woff2
Binary file not shown.
Binary file removed fonts/KaTeX_Math-Regular.ttf
Binary file not shown.
Binary file removed fonts/KaTeX_Math-Regular.woff
Binary file not shown.
Binary file removed fonts/KaTeX_Math-Regular.woff2
Binary file not shown.
Binary file modified fonts/KaTeX_SansSerif-Bold.ttf
Binary file not shown.
Binary file modified fonts/KaTeX_SansSerif-Bold.woff
Binary file not shown.
Binary file modified fonts/KaTeX_SansSerif-Bold.woff2
Binary file not shown.
Binary file modified fonts/KaTeX_SansSerif-Italic.ttf
Binary file not shown.
Binary file modified fonts/KaTeX_SansSerif-Italic.woff
Binary file not shown.
Binary file modified fonts/KaTeX_SansSerif-Italic.woff2
Binary file not shown.
Binary file modified fonts/KaTeX_SansSerif-Regular.ttf
Binary file not shown.
Binary file modified fonts/KaTeX_SansSerif-Regular.woff
Binary file not shown.
Binary file modified fonts/KaTeX_SansSerif-Regular.woff2
Binary file not shown.
Binary file modified fonts/KaTeX_Script-Regular.ttf
Binary file not shown.
Binary file modified fonts/KaTeX_Script-Regular.woff
Binary file not shown.
Binary file modified fonts/KaTeX_Script-Regular.woff2
Binary file not shown.
Binary file modified fonts/KaTeX_Size1-Regular.ttf
Binary file not shown.
Binary file modified fonts/KaTeX_Size1-Regular.woff
Binary file not shown.
Binary file modified fonts/KaTeX_Size1-Regular.woff2
Binary file not shown.
Binary file modified fonts/KaTeX_Size2-Regular.ttf
Binary file not shown.
Binary file modified fonts/KaTeX_Size2-Regular.woff
Binary file not shown.
Binary file modified fonts/KaTeX_Size2-Regular.woff2
Binary file not shown.
Binary file modified fonts/KaTeX_Size3-Regular.ttf
Binary file not shown.
Binary file modified fonts/KaTeX_Size3-Regular.woff
Binary file not shown.
Binary file modified fonts/KaTeX_Size3-Regular.woff2
Binary file not shown.
Binary file modified fonts/KaTeX_Size4-Regular.ttf
Binary file not shown.
Binary file modified fonts/KaTeX_Size4-Regular.woff
Binary file not shown.
Binary file modified fonts/KaTeX_Size4-Regular.woff2
Binary file not shown.
Binary file modified fonts/KaTeX_Typewriter-Regular.ttf
Binary file not shown.
Binary file modified fonts/KaTeX_Typewriter-Regular.woff
Binary file not shown.
Binary file modified fonts/KaTeX_Typewriter-Regular.woff2
Binary file not shown.
File renamed without changes.
32 changes: 13 additions & 19 deletions src/fonts/OTF/TeX/Makefile → src/fonts/Makefile
Expand Up @@ -17,7 +17,7 @@
# limitations under the License.
#

include ../../../custom.cfg
include ../custom.cfg

MFTRACE_MODIFIED=lib/mftrace-modified

Expand Down Expand Up @@ -76,10 +76,10 @@ pfa: $(MFTRACE_MODIFIED)
@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 "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
Expand All @@ -92,34 +92,28 @@ pfa: $(MFTRACE_MODIFIED)
ff: pfa
mkdir -p ff otf
rm -f ff/* otf/*
$(PERL) makeFF
$(PERL) makeFF

.PHONY: fonts
fonts: ff
mkdir -p ttf woff woff2
rm -f ttf/* woff/* woff2/*

# Handle the KaTeX_Size4 font first as it used by other fonts.
@echo "KaTeX_Size4.ff"
$(FONTFORGE) -lang=ff -script ff/KaTeX_Size4.ff

@for file in `cd ff; ls *.ff | $(GREP) -v KaTeX_Size4`; do \
@for file in `ls ff/*.ff | $(SED) 's|ff/\(.*\)\.ff|\1|'`; do \
echo ""; \
echo $$file; \
$(FONTFORGE) -lang=ff -script ff/$$file; \
done

@for file in `ls ttf/*.ttf`; do \
$(FONTFORGE) -lang=ff -script ff/$$file.ff; \
\
echo "Hinting $$file"; \
if echo "$$file" | $(GREP) -q -e "Size[1-4]" -e "Typewriter"; then \
$(TTFAUTOHINT) --windows-compatibility --symbol $$file $$file.hinted; \
$(TTFAUTOHINT) --windows-compatibility --symbol ttf/$$file.ttf ttf/$$file.ttf.hinted; \
else \
$(TTFAUTOHINT) --windows-compatibility $$file $$file.hinted; \
$(TTFAUTOHINT) --windows-compatibility ttf/$$file.ttf ttf/$$file.ttf.hinted; \
fi; \
mv $$file.hinted $$file; \
mv ttf/$$file.ttf.hinted ttf/$$file.ttf; \
\
echo "Generating $$file..."; \
$(PYTHON) generate_fonts.py $$file; \
$(PYTHON) generate_fonts.py ttf/$$file.ttf; \
done

clean:
Expand Down
Expand Up @@ -30,7 +30,7 @@
del font['GDEF']

# set font version from package.json
with open(os.path.join(os.path.dirname(__file__), '../../../../package.json')) as f:
with open(os.path.join(os.path.dirname(__file__), '../../package.json')) as f:
version = json.load(f)['version']

font['name'].setName(unicode('Version ' + version), 5, 3, 1, 1033)
Expand Down
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions src/fonts/OTF/TeX/makeBlacker → src/fonts/makeBlacker
Expand Up @@ -2,10 +2,10 @@

# Creates the metafont file needed for darker copies of the TeX fonts,
# and modifies mftrace to use it.
#
#
# Usage: ./makeBlacker blackness

require "../../../custom.cfg.pl";
require "../custom.cfg.pl";

$blacker = shift;
unless ($blacker) {
Expand Down

0 comments on commit 7deb3fd

Please sign in to comment.