Collection of optional fonts for PyMuPDF
Release date: December 27, 2021
This is a collection of fonts that can be used by PyMuPDF applications for writing text to PDFs.
The fonts are provided encoded in compressed base64 format, wrapped as Python variables.
The primary motivation for this approach is two-fold:
Currently the following fonts are provided:
pymupdf_fonts is a pure Python package provided as a wheel. As such it is Python version independent and can be installed via python -m pip install pymupdf-fonts.
If the package is installed, PyMuPDF supports all the fonts automatically. To use one of these fonts, simply execute font = fitz.Font("code"), where code is a value from the first table column below. So this works as if the list of standard font codes ""helv", "tiro", "cour", etc. had been extended by new codes.
You can then either use the font object directly in PyMuPDF's TextWriter class, or use its buffer in the conventional Page.insert_font() / Page.insert_text() / Page.insert_textbox() methods like this:
page.insert_font(fontname="F0", fontbuffer=font.buffer)
page.insert_text(point, text, fontname="F0", ...)
# or similarly:
page.insert_textbox(rect, text, fontname="F0", ...)For more detail consult the PyMuPDF documentation of the Font class.
| code | font | version | comment |
|---|---|---|---|
| figo | FiraGO_Regular | 1.0.0 | |
| figbo | FiraGO_Bold | 1.0.0 | |
| figit | FiraGO_Italic | 1.0.0 | |
| figbi | FiraGO_BoldItalic | 1.0.0 | |
| fimo | FiraMono_Regular | 1.0.0 | |
| fimbo | FiraMono_Bold | 1.0.0 | |
| spacemo | SpaceMono_Regular | 1.0.1 | mono-spaced |
| spacembo | SpaceMono_Bold | 1.0.1 | mono bold |
| spacemit | SpaceMono_Italic | 1.0.1 | mono italic |
| spacembi | SpaceMono_BoldItalic | 1.0.1 | mono bold-italic |
| math | Noto Sans Math Regular | 1.0.2 | math symbols |
| music | Noto Music Regular | 1.0.2 | musical symbols |
| symbol1 | Noto Sans Symbols Regular | 1.0.2 | replaces "symb" |
| symbol2 | Noto Sans Symbols2 Regular | 1.0.2 | extended symbols |
| notos | Noto Sans Regular | 1.0.3 | similar to Arial |
| notosbi | Noto Sans Italic | 1.0.3 | |
| notosbo | Noto Sans Bold | 1.0.3 | |
| notosbi | Noto Sans Bold Italic | 1.0.3 | |
| ubuntu | Ubuntu Regular | 1.0.4 | sans-serif, for texts in Ubuntu look |
| ubuntubo | Ubuntu Bold | 1.0.4 | |
| ubuntubi | Ubuntu Bold Italic | 1.0.4 | |
| ubuntuit | Ubuntu Italic | 1.0.4 | |
| ubuntm | Ubuntu Mono Regular | 1.0.4 | mono-spaced version of Ubuntu fonts |
| ubuntmbo | Ubuntu Mono Bold | 1.0.4 | |
| ubuntmbi | Ubuntu Mono Bold Italic | 1.0.4 | |
| ubuntmit | Ubuntu Mono Italic | 1.0.4 | |
| cascadia | Cascadia Mono Regular | 1.0.5 | |
| cascadiab | Cascadia Mono Bold | 1.0.5 | |
| cascadiai | Cascadia Mono Italic | 1.0.5 | |
| cascadiabi | Cascadia Mono BoldItalic | 1.0.5 |
Most of the fonts above are licensed under the SIL OFL v1.1 license, which is stored as file LICENSE.txt in this repository.
The Ubuntu fonts are available under a similar free license, to be found here: Ubuntu Font License.