Skip to content

Commit

Permalink
Fix Dockerfile to use Noto fonts and Python3
Browse files Browse the repository at this point in the history
  • Loading branch information
y-yu committed Jul 16, 2018
1 parent df1665e commit 96a800c
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 23 deletions.
48 changes: 35 additions & 13 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ ENV FONT_DEPS \
ENV FONT_PATH /usr/share/fonts/

ENV PERSISTENT_DEPS \
python \
py2-pip \
python3 \
wget \
make \
perl \
Expand All @@ -52,18 +51,41 @@ RUN apk add --no-cache --virtual .persistent-deps $PERSISTENT_DEPS
# Setup fonts
RUN mkdir -p $FONT_PATH && \
apk add --no-cache --virtual .font-deps $FONT_DEPS && \
# Noto Serif
wget https://noto-website-2.storage.googleapis.com/pkgs/NotoSerif-unhinted.zip && \
unzip -d NotoSerif-unhinted NotoSerif-unhinted.zip && \
cp NotoSerif-unhinted/*.ttf $FONT_PATH && \
rm -rf NotoSerif-unhinted.zip NotoSerif-unhinted && \
# Noto Naskh Arabic
wget https://noto-website-2.storage.googleapis.com/pkgs/NotoNaskhArabic-unhinted.zip && \
unzip -d NotoNaskhArabic-unhinted NotoNaskhArabic-unhinted.zip && \
cp NotoNaskhArabic-unhinted/*.ttf $FONT_PATH && \
rm -rf NotoNaskhArabic-unhinted.zip NotoNaskhArabic-unhinted && \
# Noto Serif CJK JP
wget https://noto-website-2.storage.googleapis.com/pkgs/NotoSerifCJKjp-hinted.zip && \
unzip -d NotoSerifCJKjp-hinted NotoSerifCJKjp-hinted.zip && \
cp NotoSerifCJKjp-hinted/*.otf $FONT_PATH && \
rm -rf NotoSerifCJKjp-hinted.zip NotoSerifCJKjp-hinted && \
# Noto Sans Devanagari
wget https://noto-website-2.storage.googleapis.com/pkgs/NotoSansDevanagari-unhinted.zip && \
unzip -d NotoSansDevanagari-unhinted NotoSansDevanagari-unhinted.zip && \
cp NotoSansDevanagari-unhinted/*.ttf $FONT_PATH && \
rm -rf NotoSansDevanagari-unhinted.zip NotoSansDevanagari-unhinted && \
# Noto Emoji
wget https://noto-website-2.storage.googleapis.com/pkgs/NotoEmoji-unhinted.zip && \
unzip -d NotoEmoji-unhinted NotoEmoji-unhinted.zip && \
cp NotoEmoji-unhinted/*.ttf $FONT_PATH && \
rm -rf NotoEmoji-unhinted.zip NotoEmoji-unhinted && \
# Noto Sans Hebrew
wget https://noto-website-2.storage.googleapis.com/pkgs/NotoSansHebrew-unhinted.zip && \
unzip -d NotoSansHebrew-unhinted NotoSansHebrew-unhinted.zip && \
cp NotoSansHebrew-unhinted/*.ttf $FONT_PATH && \
rm -rf NotoSansHebrew-unhinted.zip NotoSansHebrew-unhinted && \
# Source Code Pro
wget https://github.com/adobe-fonts/source-code-pro/archive/2.030R-ro/1.050R-it.zip && \
unzip 1.050R-it.zip && \
cp source-code-pro-2.030R-ro-1.050R-it/OTF/*.otf $FONT_PATH && \
rm -rf 1.050R-it.zip source-code-pro-2.030R-ro-1.050R-it && \
wget https://github.com/adobe-fonts/source-han-sans/raw/release/SubsetOTF/SourceHanSansJP.zip && \
unzip SourceHanSansJP.zip && \
cp SourceHanSansJP/*.otf $FONT_PATH && \
rm -rf SourceHanSansJP.zip SourceHanSansJP && \
wget https://github.com/adobe-fonts/source-han-serif/raw/release/SubsetOTF/SourceHanSerifJP.zip && \
unzip SourceHanSerifJP.zip && \
cp SourceHanSerifJP/*.otf $FONT_PATH && \
rm -rf SourceHanSerifJP.zip SourceHanSerifJP && \
fc-cache -f -v && \
apk del .font-deps

Expand All @@ -83,8 +105,8 @@ RUN apk add --no-cache --virtual .pandoc-deps $PANDOC_DEPS && \

# Install Pandocfilter
COPY requirements.txt ./
RUN pip install --upgrade pip && \
pip install -r requirements.txt && \
RUN pip3 install --upgrade pip && \
pip3 install -r requirements.txt && \
rm requirements.txt

# Install TeXLive
Expand All @@ -110,4 +132,4 @@ VOLUME ["/workdir"]

WORKDIR /workdir

ENTRYPOINT ["/bin/bash", "-c", "./setup.sh && USE_SOURCEHAN=true make"]
ENTRYPOINT ["/bin/bash", "-c", "./setup.sh && make"]
2 changes: 1 addition & 1 deletion python/body.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import sys, re
Expand Down
7 changes: 1 addition & 6 deletions python/fix_headers.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import os
import sys, base64, re
from pandocfilters import toJSONFilter, Header

reload(sys)
sys.setdefaultencoding('utf8')

def action(key, value, fmt, meta):
# Header Int Attr [Inline]
if key == 'Header':
Expand Down
3 changes: 2 additions & 1 deletion python/fix_pdf_tex.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env python
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import re
import sys
Expand Down
4 changes: 2 additions & 2 deletions setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ do
PDFTEX=`pwd`/${BASH_REMATCH[1]}.pdf_tex
inkscape -z -D --file="$SVG" --export-pdf="$PDF" --export-latex
PAGES=$(egrep -a '/Type /Page\b' "$PDF" | wc -l | tr -d ' ')
python ./python/fix_pdf_tex.py "$PAGES" < "$PDFTEX" > "$PDFTEX.tmp"
python3 ./python/fix_pdf_tex.py "$PAGES" < "$PDFTEX" > "$PDFTEX.tmp"
mv "$PDFTEX.tmp" "$PDFTEX"
fi
done
Expand All @@ -44,4 +44,4 @@ do
--pdf-engine=lualatex --top-level-division=chapter --listings $FILTERS $f
done

python ./python/body.py < ./target/SUMMARY.md > body.tex
python3 ./python/body.py < ./target/SUMMARY.md > body.tex

0 comments on commit 96a800c

Please sign in to comment.