fix(fonts): fix the timestamp of fonts to the epoch (#3370)

* fix: fix the timestamp of fonts to the epoch

* fix: update fonts

Co-authored-by: Erik Demaine <edemaine@mit.edu>
This commit is contained in:
ylemkimon
2021-10-30 04:08:22 +09:00
committed by GitHub
parent 052f0006f1
commit dde05db6b7
64 changed files with 3 additions and 13 deletions

View File

@@ -97,13 +97,11 @@ jobs:
- name: Build fonts - name: Build fonts
run: | run: |
export SOURCE_DATE_EPOCH=$(git log -1 --format=%ct -- src/fonts)
make -C src/fonts all make -C src/fonts all
rm -f fonts/*.* rm -f fonts/*.*
cp src/fonts/ttf/*.ttf fonts cp src/fonts/ttf/*.ttf fonts
cp src/fonts/woff/*.woff fonts cp src/fonts/woff/*.woff fonts
cp src/fonts/woff2/*.woff2 fonts cp src/fonts/woff2/*.woff2 fonts
echo $SOURCE_DATE_EPOCH > fonts/VERSION
- name: Build metrics - name: Build metrics
run: ./dockers/fonts/buildMetrics.sh run: ./dockers/fonts/buildMetrics.sh

View File

@@ -40,7 +40,6 @@ cleanup() {
CONTAINER= CONTAINER=
trap cleanup EXIT trap cleanup EXIT
LAST_COMMIT_DATE="$(git log -1 --format=%ct -- src/fonts)"
IMAGE="katex/fonts:DF-$(openssl sha1 dockers/fonts/Dockerfile | tail -c 9)" IMAGE="katex/fonts:DF-$(openssl sha1 dockers/fonts/Dockerfile | tail -c 9)"
TMPFILE="$(mktemp "${TMPDIR:-/tmp}/mjf.XXXXXXXX")" TMPFILE="$(mktemp "${TMPDIR:-/tmp}/mjf.XXXXXXXX")"
FILE="$TMPFILE" FILE="$TMPFILE"
@@ -59,7 +58,6 @@ if [[ $(docker images "$IMAGE" | wc -l) -lt 2 ]]; then
fi fi
CMDS="set -ex CMDS="set -ex
export SOURCE_DATE_EPOCH=${LAST_COMMIT_DATE}
tar xfP katex-fonts.tar.gz tar xfP katex-fonts.tar.gz
make -C fonts all make -C fonts all
tar cf /fonts.tar ${filetypes[*]/#/fonts/}" tar cf /fonts.tar ${filetypes[*]/#/fonts/}"
@@ -84,5 +82,3 @@ for filetype in "${filetypes[@]}"; do
done done
done done
rm -rf temp fonts.tar rm -rf temp fonts.tar
echo $LAST_COMMIT_DATE > fonts/VERSION

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -1 +0,0 @@
1630515774

View File

@@ -15,13 +15,12 @@ if len(sys.argv) < 2:
font_file = sys.argv[1] font_file = sys.argv[1]
font_name = os.path.splitext(os.path.basename(font_file))[0] font_name = os.path.splitext(os.path.basename(font_file))[0]
# now or SOURCE_DATE_EPOCH, if present
timestamp = timestampNow()
font = TTFont(font_file, recalcBBoxes=False, recalcTimestamp=False) font = TTFont(font_file, recalcBBoxes=False, recalcTimestamp=False)
font['head'].created = timestamp # fix timestamp to the epoch
font['head'].modified = timestamp font['head'].created = 0
font['head'].modified = 0
# remove fontforge timestamps # remove fontforge timestamps
if 'FFTM' in font: if 'FFTM' in font:
@@ -36,8 +35,6 @@ if 'GDEF' in font:
font['name'].names = [record for record in font['name'].names if record.platformID != 1] 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['cmap'].tables = [table for table in font['cmap'].tables if table.platformID != 1]
font['name'].setName('Version ' + str(timestamp), 5, 3, 1, 1033)
# fix OS/2 and hhea metrics # fix OS/2 and hhea metrics
glyf = font['glyf'] glyf = font['glyf']
ascent = int(max(glyf[c].yMax for c in font.getGlyphOrder() if hasattr(glyf[c], "yMax"))) ascent = int(max(glyf[c].yMax for c in font.getGlyphOrder() if hasattr(glyf[c], "yMax")))