How to add new font e.g "SimHei" when building a binder?

I want to include Chinese characters in my output. How to add a font when I build the binder link?

That depends on how you want to install the font. You might want an apt.txt if it’s an apt package. How are you producing the output with the characters?

You can see a list of available font packages on Ubuntu.

For example:



If you’d install it manually, a postbuild script can be used to download font packages.

But also, if it’s notebook output, fonts in the image shouldn’t matter because fonts are loaded from the browser viewing the page, not the Binder container where code runs. Installing fonts in the image should only be needed if you are doing rendering in code (e.g. matplotlib figures).


Thank you for the help!
I’m rendering a digram in code using matplotlib. It works fine in my local machine I manually downloaded the font and went through a process made it work, but not with the binder.
Is postbuild script a platform? How does it work?

postBuild is a type of configuration file you can place in your repo or binder directory to specify something to do after the image for the repository is built but before a session is launched using that image. See here.

There’s a number of examples among the sample repos. Just search ‘postBuild’ on that page to have them highlighted.


here are the repo2docker docs for apt.txt and postBuild. They need to exist in one of the following paths in the repo:

  • ./
  • ./binder
  • ./.binder (this is the “cleanest” UI, as it will be hidden from the file browser, if that’s desirable)