Skip to content

Commit

Permalink
Merge pull request #1508 from ggaaooppeenngg/custom-font-recipe
Browse files Browse the repository at this point in the history
Add recipe for installing custom fonts
  • Loading branch information
mathbunnyru committed Nov 2, 2021
2 parents ae640b0 + e76894f commit c400462
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions docs/using/recipes.md
Original file line number Diff line number Diff line change
Expand Up @@ -549,3 +549,20 @@ RUN echo "from pyspark.sql import SparkSession" > /tmp/init-delta.py && \
python /tmp/init-delta.py && \
rm /tmp/init-delta.py
```

## Add Custom Font in Scipy notebook

The example below is a Dockerfile to load Source Han Sans with normal weight which is usually used for web.

```dockerfile
FROM jupyter/scipy-notebook:latest

RUN PYV=$(ls "${CONDA_DIR}/lib" | grep ^python) && \
MPL_DATA="${CONDA_DIR}/lib/${PYV}/site-packages/matplotlib/mpl-data" && \
wget --quiet -P "${MPL_DATA}/fonts/ttf/" https://mirrors.cloud.tencent.com/adobe-fonts/source-han-sans/SubsetOTF/CN/SourceHanSansCN-Normal.otf && \
sed -i 's/#font.family/font.family/g' "${MPL_DATA}/matplotlibrc" && \
sed -i 's/#font.sans-serif:/font.sans-serif: Source Han Sans CN,/g' "${MPL_DATA}/matplotlibrc" && \
sed -i 's/#axes.unicode_minus: True/axes.unicode_minus: False/g' "${MPL_DATA}/matplotlibrc" && \
rm -rf "/home/${NB_USER}/.cache/matplotlib" && \
python -c 'import matplotlib.font_manager;print("font loaded: ",("Source Han Sans CN" in [f.name for f in matplotlib.font_manager.fontManager.ttflist]))'
```

0 comments on commit c400462

Please sign in to comment.