fix(fonts): update fonts dependencies (#2866)
* fix(fonts): update fonts dependencies * chore(fonts): fix buildMetrics for Python 3 * fix(fonts): update fonts * test: update screenshots * docs: update reference to katex-fonts * chore: use Python 3 * fix(fonts): update fonts * test: update screenshots * Use explicit path * Command-line arguments aren't actually supported * Small buildMetrics fixes * Add build:{fonts,metrics} script * Lock versions of font-related dependencies * Install minimal texlive * Install fontforge Co-authored-by: Erik Demaine <edemaine@mit.edu>
@@ -1,40 +1,21 @@
|
||||
FROM ubuntu:14.04.5
|
||||
MAINTAINER xymostech <xymostech@gmail.com>
|
||||
FROM ubuntu:20.04
|
||||
|
||||
# Install things
|
||||
RUN apt-get update \
|
||||
&& DEBIAN_FRONTEND=noninteractive apt-get -y upgrade \
|
||||
&& DEBIAN_FRONTEND=noninteractive apt-get -y install \
|
||||
--no-install-recommends --auto-remove \
|
||||
software-properties-common \
|
||||
texlive \
|
||||
wget \
|
||||
fontforge \
|
||||
mftrace \
|
||||
man-db \
|
||||
build-essential \
|
||||
python-fontforge \
|
||||
python-dev \
|
||||
python-pip \
|
||||
pkg-config \
|
||||
libharfbuzz-dev \
|
||||
libfreetype6-dev \
|
||||
libjson-perl \
|
||||
&& add-apt-repository ppa:git-core/ppa \
|
||||
&& apt-get update \
|
||||
&& DEBIAN_FRONTEND=noninteractive apt-get -y install \
|
||||
--no-install-recommends --auto-remove \
|
||||
git \
|
||||
texlive-base \
|
||||
texlive-fonts-recommended \
|
||||
fontforge=1:20190801~dfsg-4 \
|
||||
mftrace=1.2.20+git20190918.fd8fef5-2 \
|
||||
build-essential \
|
||||
python3-fontforge=1:20190801~dfsg-4 \
|
||||
python3-dev \
|
||||
python3-pip \
|
||||
ttfautohint=1.8.3-2build1 \
|
||||
libjson-perl \
|
||||
&& apt-get clean \
|
||||
&& rm -rf /var/lib/apt/lists/* \
|
||||
&& pip install fonttools==3.28.0 brotli zopfli
|
||||
|
||||
# Download and compile ttfautohint
|
||||
RUN wget "http://download.savannah.gnu.org/releases/freetype/ttfautohint-1.3.tar.gz" \
|
||||
&& tar -xzf ttfautohint-*.tar.gz \
|
||||
&& cd ttfautohint-*/ \
|
||||
&& ./configure --without-qt \
|
||||
&& make \
|
||||
&& mv frontend/ttfautohint /usr/bin \
|
||||
&& cd .. \
|
||||
&& rm -r ttfautohint-*
|
||||
&& pip3 install fonttools==4.21.1 brotli zopfli
|
||||
|
@@ -7,13 +7,6 @@ Originally based on MathJax font generation
|
||||
The `buildFonts.sh` script should do everything automatically,
|
||||
as long as Docker is installed.
|
||||
|
||||
If you want to try out a change
|
||||
to [the katex-fonts repository](https://github.com/KaTeX/katex-fonts),
|
||||
create a local clone (or download and unpack the ZIP file)
|
||||
and specify the path to this directory as an argument to `buildFonts.sh`.
|
||||
You can also specify a local or remote tarball,
|
||||
e.g. a GitHub download of your own personal feature branch.
|
||||
|
||||
The script `buildFonts.sh` automatically creates Docker images
|
||||
from the supplied `Dockerfile`.
|
||||
It uses the hash of the file to tag the image, so a change to the file
|
||||
|
@@ -1,19 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
shopt -s extglob
|
||||
|
||||
usage() {
|
||||
while [[ $# -gt 1 ]]; do
|
||||
echo "$1" >&2
|
||||
shift
|
||||
done
|
||||
echo "Usage: ${0##*/} [OPTIONS]"
|
||||
echo ""
|
||||
echo "OPTIONS:"
|
||||
echo " -h|--help display this help"
|
||||
echo " --image NAME:TAG use the named docker image [$IMAGE]"
|
||||
exit $1
|
||||
}
|
||||
|
||||
used_fonts=(
|
||||
KaTeX_AMS-Regular
|
||||
KaTeX_Caligraphic-Bold
|
||||
@@ -54,7 +41,7 @@ CONTAINER=
|
||||
trap cleanup EXIT
|
||||
|
||||
LAST_COMMIT_DATE="$(git log -1 --format=%ct -- src/fonts)"
|
||||
IMAGE="katex/fonts:DF-$(openssl sha1 $(dirname "$0")/Dockerfile | tail -c 9)"
|
||||
IMAGE="katex/fonts:DF-$(openssl sha1 dockers/fonts/Dockerfile | tail -c 9)"
|
||||
TMPFILE="$(mktemp "${TMPDIR:-/tmp}/mjf.XXXXXXXX")"
|
||||
FILE="$TMPFILE"
|
||||
pushd "src"
|
||||
@@ -68,7 +55,7 @@ popd
|
||||
# build image if missing
|
||||
if [[ $(docker images "$IMAGE" | wc -l) -lt 2 ]]; then
|
||||
echo "Need to build docker image $IMAGE"
|
||||
docker build --tag "$IMAGE" "$(dirname "$0")"
|
||||
docker build --tag "$IMAGE" "dockers/fonts"
|
||||
fi
|
||||
|
||||
CMDS="set -ex
|
||||
|
@@ -1,7 +1,7 @@
|
||||
#!/bin/sh
|
||||
# Generates fontMetricsData.js
|
||||
PERL="perl"
|
||||
PYTHON=`python2 --version >/dev/null 2>&1 && echo python2 || echo python`
|
||||
PYTHON="python3"
|
||||
|
||||
cd src/metrics
|
||||
cd "$(dirname "$0")/../../src/metrics"
|
||||
$PERL ./mapping.pl | $PYTHON ./extract_tfms.py | $PYTHON ./extract_ttfs.py | $PYTHON ./format_json.py --width > ../fontMetricsData.js
|
||||
|
@@ -41,6 +41,6 @@ variable to `"true"` or `"false"`, respectively.
|
||||
|
||||
The default build of KaTeX expects the KaTeX fonts to be located in a directory called `fonts` which is a sibling of the `katex.min.css` stylesheet. This can be changed as follows:
|
||||
|
||||
1. At the top of the [fonts.less](https://github.com/KaTeX/katex-fonts/blob/master/fonts.less) file, set `@font-folder` to the location of your fonts. You can use relative or absolute paths, so setting it to `"/fonts"` would cause it to search for the fonts in a root `fonts` folder, while `"../fonts"` would search in a `fonts` directory one level above the `katex.min.css` file.
|
||||
1. At the top of the [fonts.less](https://github.com/KaTeX/KaTeX/blob/master/src/fonts.less) file, set `@font-folder` to the location of your fonts. You can use relative or absolute paths, so setting it to `"/fonts"` would cause it to search for the fonts in a root `fonts` folder, while `"../fonts"` would search in a `fonts` directory one level above the `katex.min.css` file.
|
||||
2. Rebuild KaTeX by running `yarn build` from the top-level directory.
|
||||
3. Use the newly generated `dist/katex.min.css` file, and place the fonts where you indicated.
|
||||
|
@@ -1 +1 @@
|
||||
1615612969
|
||||
1617112426
|
||||
|
@@ -105,6 +105,8 @@
|
||||
"start": "webpack serve --config webpack.dev.js",
|
||||
"analyze": "webpack --config webpack.analyze.js",
|
||||
"build": "rimraf dist/ && mkdirp dist && cp README.md dist && rollup -c --failAfterWarnings && webpack && node update-sri.js package dist/README.md",
|
||||
"build:fonts": "dockers/fonts/buildFonts.sh",
|
||||
"build:metrics": "dockers/fonts/buildMetrics.sh",
|
||||
"watch": "yarn build --watch",
|
||||
"postversion": "yarn dist && node update-sri.js package README.md contrib/*/README.md docs/*.md website/pages/index.html",
|
||||
"semantic-release": "semantic-release",
|
||||
|
@@ -1038,7 +1038,7 @@ export default {
|
||||
"8221": [0, 0.69444, 0, 0, 0.5],
|
||||
"8224": [0.19444, 0.69444, 0, 0, 0.44445],
|
||||
"8225": [0.19444, 0.69444, 0, 0, 0.44445],
|
||||
"8230": [0, 0.12, 0, 0, 1.172],
|
||||
"8230": [0, 0.123, 0, 0, 1.172],
|
||||
"8242": [0, 0.55556, 0, 0, 0.275],
|
||||
"8407": [0, 0.71444, 0.15382, 0, 0.5],
|
||||
"8463": [0, 0.68889, 0, 0, 0.54028],
|
||||
@@ -1102,7 +1102,7 @@ export default {
|
||||
"8773": [-0.022, 0.589, 0, 0, 1.0],
|
||||
"8776": [-0.01688, 0.48312, 0, 0, 0.77778],
|
||||
"8781": [-0.03625, 0.46375, 0, 0, 0.77778],
|
||||
"8784": [-0.133, 0.67, 0, 0, 0.778],
|
||||
"8784": [-0.133, 0.673, 0, 0, 0.778],
|
||||
"8801": [-0.03625, 0.46375, 0, 0, 0.77778],
|
||||
"8804": [0.13597, 0.63597, 0, 0, 0.77778],
|
||||
"8805": [0.13597, 0.63597, 0, 0, 0.77778],
|
||||
@@ -1133,9 +1133,9 @@ export default {
|
||||
"8901": [-0.05555, 0.44445, 0, 0, 0.27778],
|
||||
"8902": [-0.03472, 0.46528, 0, 0, 0.5],
|
||||
"8904": [0.005, 0.505, 0, 0, 0.9],
|
||||
"8942": [0.03, 0.9, 0, 0, 0.278],
|
||||
"8943": [-0.19, 0.31, 0, 0, 1.172],
|
||||
"8945": [-0.1, 0.82, 0, 0, 1.282],
|
||||
"8942": [0.03, 0.903, 0, 0, 0.278],
|
||||
"8943": [-0.19, 0.313, 0, 0, 1.172],
|
||||
"8945": [-0.1, 0.823, 0, 0, 1.282],
|
||||
"8968": [0.25, 0.75, 0, 0, 0.44445],
|
||||
"8969": [0.25, 0.75, 0, 0, 0.44445],
|
||||
"8970": [0.25, 0.75, 0, 0, 0.44445],
|
||||
@@ -1143,7 +1143,7 @@ export default {
|
||||
"8994": [-0.14236, 0.35764, 0, 0, 1.0],
|
||||
"8995": [-0.14236, 0.35764, 0, 0, 1.0],
|
||||
"9136": [0.244, 0.744, 0, 0, 0.412],
|
||||
"9137": [0.244, 0.744, 0, 0, 0.412],
|
||||
"9137": [0.244, 0.745, 0, 0, 0.412],
|
||||
"9651": [0.19444, 0.69444, 0, 0, 0.88889],
|
||||
"9657": [-0.03472, 0.46528, 0, 0, 0.5],
|
||||
"9661": [0.19444, 0.69444, 0, 0, 0.88889],
|
||||
@@ -1159,7 +1159,7 @@ export default {
|
||||
"10216": [0.25, 0.75, 0, 0, 0.38889],
|
||||
"10217": [0.25, 0.75, 0, 0, 0.38889],
|
||||
"10222": [0.244, 0.744, 0, 0, 0.412],
|
||||
"10223": [0.244, 0.744, 0, 0, 0.412],
|
||||
"10223": [0.244, 0.745, 0, 0, 0.412],
|
||||
"10229": [0.011, 0.511, 0, 0, 1.609],
|
||||
"10230": [0.011, 0.511, 0, 0, 1.638],
|
||||
"10231": [0.011, 0.511, 0, 0, 1.859],
|
||||
|
@@ -42,7 +42,7 @@ config: $(CUSTOM).pl
|
||||
|
||||
blacker: $(MFTRACE_MODIFIED)
|
||||
$(MFTRACE_MODIFIED):
|
||||
$(PERL) makeBlacker 15 # values between 10 and 30 seem best
|
||||
$(PERL) -I. makeBlacker 15 # values between 10 and 30 seem best
|
||||
|
||||
pfa: $(MFTRACE_MODIFIED)
|
||||
@echo "cmr10"
|
||||
@@ -109,7 +109,7 @@ pfa: $(MFTRACE_MODIFIED)
|
||||
ff: pfa
|
||||
mkdir -p ff otf
|
||||
rm -f ff/* otf/*
|
||||
$(PERL) makeFF
|
||||
$(PERL) -I. makeFF
|
||||
|
||||
.PHONY: fonts
|
||||
fonts: ff
|
||||
|
@@ -3,7 +3,7 @@
|
||||
##### Standard programs #####
|
||||
GREP=grep
|
||||
PERL=perl
|
||||
PYTHON=python
|
||||
PYTHON=python3
|
||||
SED=sed
|
||||
WHICH=which
|
||||
KPSEWHICH=kpsewhich
|
||||
|
@@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python2
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import sys
|
||||
import os
|
||||
@@ -9,7 +9,7 @@ from fontTools.misc.timeTools import timestampNow
|
||||
sfnt.USE_ZOPFLI = True
|
||||
|
||||
if len(sys.argv) < 2:
|
||||
print "Usage: %s <font file>" % sys.argv[0]
|
||||
print("Usage: %s <font file>" % sys.argv[0])
|
||||
sys.exit(1)
|
||||
|
||||
font_file = sys.argv[1]
|
||||
@@ -36,7 +36,7 @@ if 'GDEF' in font:
|
||||
font['name'].names = [record for record in font['name'].names if record.platformID != 1]
|
||||
font['cmap'].tables = [table for table in font['cmap'].tables if table.platformID != 1]
|
||||
|
||||
font['name'].setName(unicode('Version ' + str(timestamp)), 5, 3, 1, 1033)
|
||||
font['name'].setName('Version ' + str(timestamp), 5, 3, 1, 1033)
|
||||
|
||||
# fix OS/2 and hhea metrics
|
||||
glyf = font['glyf']
|
||||
|
@@ -17,7 +17,7 @@ There are several requirements for generating the metrics used by KaTeX.
|
||||
|
||||
Once you have these things, run the following command from the root directory:
|
||||
|
||||
sh ./docker/fonts/buildMetrics.sh
|
||||
sh ./dockers/fonts/buildMetrics.sh
|
||||
|
||||
which should generate new metrics and place them into `fontMetricsData.json`.
|
||||
You're done!
|
||||
|
@@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import collections
|
||||
import json
|
||||
@@ -74,8 +74,8 @@ def main():
|
||||
|
||||
families = collections.defaultdict(dict)
|
||||
|
||||
for family, chars in mapping.iteritems():
|
||||
for char, char_data in chars.iteritems():
|
||||
for family, chars in mapping.items():
|
||||
for char, char_data in chars.items():
|
||||
char_num = int(char)
|
||||
|
||||
font = char_data['font']
|
||||
|
@@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
|
||||
from fontTools.ttLib import TTFont
|
||||
import sys
|
||||
@@ -76,7 +76,7 @@ def main():
|
||||
chars[u"\u0020"] = None # space
|
||||
chars[u"\u00a0"] = None # nbsp
|
||||
|
||||
for char, base_char in chars.iteritems():
|
||||
for char, base_char in chars.items():
|
||||
code = ord(char)
|
||||
names = set(t.get(code) for t in cmap)
|
||||
if not names:
|
||||
|
2
src/metrics/format_json.py
Normal file → Executable file
@@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import sys
|
||||
import json
|
||||
|
Before Width: | Height: | Size: 7.0 KiB After Width: | Height: | Size: 7.0 KiB |
Before Width: | Height: | Size: 9.3 KiB After Width: | Height: | Size: 9.3 KiB |
Before Width: | Height: | Size: 7.4 KiB After Width: | Height: | Size: 7.4 KiB |
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
Before Width: | Height: | Size: 9.5 KiB After Width: | Height: | Size: 9.5 KiB |
Before Width: | Height: | Size: 8.8 KiB After Width: | Height: | Size: 8.8 KiB |
Before Width: | Height: | Size: 9.0 KiB After Width: | Height: | Size: 9.0 KiB |
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
Before Width: | Height: | Size: 30 KiB After Width: | Height: | Size: 30 KiB |
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 28 KiB |
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 18 KiB |
Before Width: | Height: | Size: 6.5 KiB After Width: | Height: | Size: 6.5 KiB |
Before Width: | Height: | Size: 6.5 KiB After Width: | Height: | Size: 6.5 KiB |
Before Width: | Height: | Size: 6.7 KiB After Width: | Height: | Size: 6.7 KiB |
Before Width: | Height: | Size: 4.8 KiB After Width: | Height: | Size: 4.8 KiB |
Before Width: | Height: | Size: 4.8 KiB After Width: | Height: | Size: 4.8 KiB |
Before Width: | Height: | Size: 4.9 KiB After Width: | Height: | Size: 4.9 KiB |
Before Width: | Height: | Size: 23 KiB After Width: | Height: | Size: 23 KiB |