Add the ability to add woff2 files to the docker
Summary: To complement pull request #142, add the ability to automatically generate the woff2 files from within the docker. Add a script for copying out the generated font files to make things easier. Remove the KaTeX_Greek font files as well as the KaTeX_Win ones, since we don't use them and they're oddly non-woff and non-eot specific? Test Plan: - Build a new docker from the new Dockerfile - Make sure the woff2_compress program compiles - Follow the instructions in the README to build the fonts - Make sure the fonts correctly build - Make sure the copy_fonts.sh script copies the fonts out Reviewers: alpert Reviewed By: alpert Differential Revision: http://phabricator.khanacademy.org/D13637
This commit is contained in:
parent
4c00064f41
commit
10e9b4ec12
|
@ -3,7 +3,7 @@ MAINTAINER xymostech <xymostech@gmail.com>
|
|||
|
||||
# Install things
|
||||
RUN apt-get -qq update
|
||||
RUN apt-get -qqy install git dvipng default-jre default-jdk texlive wget fontforge mftrace fonttools optipng advancecomp man-db build-essential unzip zlib1g-dev python-fontforge ruby || true
|
||||
RUN apt-get -qqy install git dvipng default-jre default-jdk texlive wget fontforge mftrace fonttools optipng advancecomp man-db build-essential unzip zlib1g-dev python-fontforge ruby woff-tools || true
|
||||
RUN gem install ttfunk --version 1.1.1
|
||||
|
||||
# Download yuicompressor
|
||||
|
@ -22,11 +22,10 @@ RUN sed -i "1s/^/#include <cstddef>/" ttf2eot-0.0.2-2/OpenTypeUtilities.h
|
|||
RUN make -C ttf2eot-0.0.2-2/
|
||||
RUN mv ttf2eot-0.0.2-2/ttf2eot /usr/bin/
|
||||
|
||||
# Download and compile sfnt2woff
|
||||
RUN wget "http://people.mozilla.org/~jkew/woff/woff-code-latest.zip"
|
||||
RUN unzip -d sfnt2woff woff-code-latest.zip
|
||||
RUN make -C sfnt2woff
|
||||
RUN mv sfnt2woff/sfnt2woff /usr/bin/
|
||||
# Download and compile woff2_compress
|
||||
RUN git clone "https://code.google.com/p/font-compression-reference/" woff2_compress
|
||||
RUN make -C woff2_compress/woff2/
|
||||
RUN mv woff2_compress/woff2/woff2_compress /usr/bin/
|
||||
|
||||
# Download and setup MathJax-dev
|
||||
RUN git clone "https://github.com/khan/MathJax-dev.git"
|
||||
|
|
|
@ -23,26 +23,15 @@ or use a different name.) This will get you into the docker in the root
|
|||
directory. From there, cd into the `/MathJax-dev/fonts/OTF/TeX` directory, and
|
||||
run
|
||||
|
||||
make ttf eot woff
|
||||
make ttf eot woff woff2
|
||||
|
||||
to build all of the fonts that we need. Finally, leave the docker and copy all
|
||||
the files off with
|
||||
the files off with the `copy_fonts.sh` script:
|
||||
|
||||
docker cp mjf:/MathJax-dev/fonts/OTF/TeX/ttf ./
|
||||
docker cp mjf:/MathJax-dev/fonts/OTF/TeX/eot ./
|
||||
docker cp mjf:/MathJax-dev/fonts/OTF/TeX/woff ./
|
||||
./copy_fonts.sh mjf
|
||||
|
||||
(note we're using `mjf:` to specify the name of the docker we created above)
|
||||
Compile the fonts into a single directory
|
||||
|
||||
mv {ttf,eot,woff}/* ./
|
||||
|
||||
Remove the WinIE6 and WinChrome fonts
|
||||
|
||||
rm KaTeX_Win*
|
||||
|
||||
And you're good to go! Don't forget to update the font metrics with the
|
||||
metric_parse.rb script once you're done.
|
||||
And you're good to go! Don't forget to update the font metrics with `make
|
||||
metrics`.
|
||||
|
||||
### General Docker Help
|
||||
-----------------------
|
||||
|
|
47
dockers/MathJaxFonts/copy_fonts.sh
Executable file
47
dockers/MathJaxFonts/copy_fonts.sh
Executable file
|
@ -0,0 +1,47 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
if [ -z "$1" ]; then
|
||||
echo "Usage: $(basename $0) <docker name>"
|
||||
echo " If you followed the README, the docker name would be 'mjf'"
|
||||
exit 1
|
||||
else
|
||||
DOCKER_NAME="$1"
|
||||
fi
|
||||
|
||||
mkdir fonts
|
||||
|
||||
used_fonts=(
|
||||
KaTeX_AMS-Regular
|
||||
KaTeX_Caligraphic-Bold
|
||||
KaTeX_Caligraphic-Regular
|
||||
KaTeX_Fraktur-Bold
|
||||
KaTeX_Fraktur-Regular
|
||||
KaTeX_Main-Bold
|
||||
KaTeX_Main-Italic
|
||||
KaTeX_Main-Regular
|
||||
KaTeX_Math-BoldItalic
|
||||
KaTeX_Math-Italic
|
||||
KaTeX_Math-Regular
|
||||
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
|
||||
)
|
||||
|
||||
for filetype in ttf eot woff woff2; do
|
||||
echo "Copying $filetype"
|
||||
docker cp "$DOCKER_NAME":/MathJax-dev/fonts/OTF/TeX/"$filetype" fonts
|
||||
|
||||
for font in ${used_fonts[*]}; do
|
||||
mv fonts/"$filetype"/"$font"* fonts/
|
||||
done
|
||||
|
||||
rm -rf fonts/"$filetype"
|
||||
done
|
File diff suppressed because one or more lines are too long
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.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user