Skip to content

Commit 37348f8

Browse files
committed
upload v1.0.4
1 parent bc7a4e1 commit 37348f8

File tree

12 files changed

+16357
-32
lines changed

12 files changed

+16357
-32
lines changed

PKG-INFO

Lines changed: 35 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Metadata-Version: 1.1
22
Name: pymupdf_fonts
3-
Version: 1.0.3
3+
Version: 1.0.4
44
Author: Jorj McKie
55
Author-email: [email protected]
66
License: SIL OFL V1.1
@@ -10,39 +10,51 @@ Home-page: https://github.com/pymupdf/pymupdf_fonts
1010
Download-url: https://github.com/pymupdf/pymupdf_fonts
1111
Summary: pymupdf_fonts is a collection of fonts to be used by PyMuPDF
1212
Description:
13-
Release date: March 10, 2021
14-
13+
Release date: September 19, 2021
14+
1515
Author
1616
======
17-
17+
1818
* Jorj X. McKie
19-
19+
2020
Introduction
2121
============
22-
22+
2323
This is a collection of fonts that can be used by PyMuPDF applications for writing text to PDFs.
24-
24+
2525
The fonts are provided encoded in compressed base64 format, wrapped as Python variables.
26-
27-
The primary motivation for this approach is two-fold: (1) keep the PyMuPDF binary module size within reasonable limits and (2) enable inclusion of fonts not supported by the MuPDF library. We may extend this repository with Google's NOTO fonts.
28-
29-
To use a certain font, its corresponding Python value is imported, which automatically decompresses and decodes the font's binary image into a ``bytes`` object. This value can then be used as a fontbuffer by any PyMuPDF method which needs a font.
30-
31-
Currently the following fonts made by Mozilla are provided:
32-
* **FiraGO** font family, sans serif **proportional** fonts with support for 68 languages and the following scripts: Latin, Cyrillic, Greek, Arabic, Hebrew, Thai, Georgian and Devanagari. Support for the variants Regular, Bold, Ialic and Bold-Italic. Use this font as a viable "universal" alternative to the "Droid Sans Fallback Regular" font, which is included in the PyMuPDF package (embedded in the binary extension module).
33-
* **FiraMono** font family, sans serif **mono-spaced** fonts with support for dozens of languages and the scripts Latin, Cyrillic, Greek. Supports the weights Regular and Bold (no Italic). Can be used instead of Courier for a nicer look.
34-
* **Space Mono** (new in version 1.0.1) a nice and small-sized mono-spaced font family. Space Mono is an original fixed-width type family designed by Colophon Foundry for Google Design. It supports a Latin Extended glyph set, enabling typesetting for English and other Western European languages. Part of Google Fonts and also licensed by the `Open Font License <https://scripts.sil.org/cms/scripts/page.php?site_id=nrsi&id=OFL>`. Supports Regular, Bold, Italic and Bild-Italic.
35-
26+
27+
The primary motivation for this approach is two-fold: (1) keep the PyMuPDF binary module size within reasonable limits and (2) enable inclusion of fonts not supported as part of PyMuPDF itself. We may extend this package with more Google's NOTO fonts and others over time.
28+
29+
Currently the following fonts are provided:
30+
31+
* **FiraGO** -- font family, sans serif **proportional** fonts with support for 68 languages and the following scripts: Latin, Cyrillic, Greek, Arabic, Hebrew, Thai, Georgian and Devanagari. Support for the variants Regular, Bold, Ialic and Bold-Italic. Use this font as a viable "universal" alternative to the "Droid Sans Fallback Regular" font, which is included in the PyMuPDF package (embedded in the binary extension module).
32+
* **FiraMono** -- font family, sans serif **mono-spaced** fonts with support for dozens of languages and the scripts Latin, Cyrillic, Greek. Supports the weights Regular and Bold (no Italic). Can be used instead of Courier for a nicer look.
33+
* **Space Mono** -- a nice and small-sized mono-spaced font family. Space Mono is an original fixed-width type family designed by Colophon Foundry for Google Design. It supports a Latin Extended glyph set, enabling typesetting for English and other Western European languages. Part of Google Fonts and also licensed under SIL OFL v1.1. Supports Regular, Bold, Italic and Bold-Italic.
34+
* **NOTO Sans** -- Google font family similar to Helvetica. Supports Regular, Bold, Italic and Bold-Italic.
35+
* **NOTO Music** -- Google font for musical symbols.
36+
* **NOTO SANS Math** -- Google font for mathematical symbols.
37+
* **NOTO Symbols** and **NOTO Symbols2** -- Google symbol fonts.
38+
* **Ubuntu** font families, which provide sans-serif proportional and mono-spaced fonts with a look familiar to Ubuntu users. They are licensed under a slightly different license - see below - which nonetheless offers a similar degree of freedom as the OFL.
39+
3640
Installation
3741
============
38-
39-
pymupdf_fonts is a pure Python package provided as a wheel. As such it is Python version independent. The fonts provided here are lzma-compressed. This is a standard module in Python 3.
40-
42+
43+
pymupdf-fonts is a pure Python package provided as a wheel. As such it is Python version independent.
44+
4145
Usage and Documentation
4246
========================
43-
44-
Using the fonts is documented in PyMuPDF.
45-
47+
48+
How to use fonts in general is described in detail in the PyMuPDF documentation. The basic instruction is ``font = fitz.Font("key")``, where "key" is one of the Base-14 or CJK **font codes**, like "helv", "cour" or "cjk".
49+
50+
Once this package is installed, PyMuPDF makes these fonts automatically and seamlessly available as **additional font codes**, for example ``font = fitz.Font("figo")`` for "FiraGO Regular". You do not need to import this package separately yourself. To see a list of additionally available font codes, type ``print(fitz.fitz_fontdescriptors.keys())``.
51+
52+
But you can access font information of this package **also without PyMuPDF:** just ``import pymupdf_fonts``. Its dictionary ``fontdescriptors`` equals ``fitz_fontdescriptors`` above. For example, to access the fontfile's binary content of "FiraGO Regular", execute ``fontbuffer = pymupdf_fonts.fontbuffers["figo"]()`` (a bytes object).
53+
54+
License
55+
========================
56+
57+
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007, `Open Font License <https://scripts.sil.org/cms/scripts/page.php?site_id=nrsi&id=OFL>`_. The Ubuntu fonts are licensed under the `Ubuntu Font License `<http://font.ubuntu.com/ufl/`_.
4658

4759
Classifier: Development Status :: 5 - Production/Stable
4860
Classifier: Environment :: Console

README.md

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# pymupdf-fonts
22
Collection of optional fonts for PyMuPDF
33

4-
Release date: July 31, 2020
4+
Release date: September 19, 2021
55

66
# Author
77

@@ -16,31 +16,35 @@ The fonts are provided encoded in compressed base64 format, wrapped as Python va
1616
The primary motivation for this approach is two-fold:
1717

1818
1. keep the PyMuPDF binary module size within reasonable limits by not adding more fonts to it, and
19-
2. enable the inclusion of arbitrary fonts that are not contained in the MuPDF library. We also may extend this repository with selected Google's NOTO fonts.
19+
2. enable the inclusion of arbitrary fonts that are not contained in the MuPDF library. We also may extend this repository with selected fonts.
2020

2121
Currently the following fonts are provided:
22-
* **FiraGO** font family made by Mozilla.org. These are sans serif **proportional** fonts with support for 68 languages and the following scripts: Latin, Cyrillic, Greek, Arabic, Hebrew, Thai, Georgian and Devanagari. Support for the variants **Regular**, **Bold**, **Ialic** and **Bold-Italic**. If you do not need Asian script support (CJK), use it as a viable "universal" alternative to the **"Droid Sans Fallback Regular"** font (which is part of PyMuPDF's binary).
22+
* **FiraGO** font family made by Mozilla.org. These are sans-serif **proportional** fonts with support for 68 languages and the following scripts: Latin, Cyrillic, Greek, Arabic, Hebrew, Thai, Georgian and Devanagari. They support the weights **Regular**, **Bold**, **Ialic** and **Bold-Italic**. If you do not need Asian script support (CJK), use it as a viable "universal" alternative to the **"Droid Sans Fallback Regular"** font (which is part of PyMuPDF's binary).
2323
* **FiraMono** font family made by Mozilla.org, sans serif **mono-spaced** fonts with support for dozens of languages and the scripts Latin, Cyrillic, Greek. Supports the weights **Regular** and **Bold**, but no italics. Can be used instead of Courier for a nicer look.
24-
* **Space Mono** (my personal favorite) a nice and small-sized **mono-spaced** font family. It is an original fixed-width type family designed by Colophon Foundry for Google Design. It supports a Latin Extended glyph set, enables typesetting for English and other Western European languages. Part of Google Fonts and also licensed by the [Open Font License](https://scripts.sil.org/cms/scripts/page.php?site_id=nrsi&id=OFL). Supports **Regular**, **Bold*, **Italic** and **Bold-Italic**. Can be used instead of Courier for a nicer look.
24+
* **Space Mono** (my personal favorite) a nice and small-sized **mono-spaced** font family. It is an original fixed-width type family designed by Colophon Foundry for Google Design. It supports a Latin Extended glyph set, enables typesetting for English and other Western European languages. Part of Google Fonts and also licensed under the [Open Font License](https://scripts.sil.org/cms/scripts/page.php?site_id=nrsi&id=OFL). Supports **Regular**, **Bold**, **Italic** and **Bold-Italic**. Can be used instead of Courier for a nicer look.
2525
* **Noto Sans Math Regular** a NOTO font from Google providing mathematical symbols.
2626
* **Noto Music Regular** a NOTO font from Google providing musical symbols.
2727
* **Noto Sans Symbols Regular** a Google NOTO replacement for the Base-14 Symbol font.
2828
* **Noto Sans Symbols2 Regular** an extension for the previous.
2929
* **Noto Sans** a Google NOTO font family replacement for Helvetica / Arial, which support all four weights regular, bold, italics and bold-italics.
30+
* **Ubuntu** font families of sans-serif proportional and mono-spaced fonts, that provide a look familiar to Ubuntu users. They are licensed under a slightly different license - see below - which nonetheless offers a similar degree of freedom as the OFL.
3031

3132

3233
# Installation
3334

34-
pymupdf_fonts is a pure Python package provided as a wheel. As such it is Python version independent. The fonts provided here are lzma-compressed. This is a standard module in Python 3, but not in Python 2. Therefore, there is **no support for Python 2**.
35+
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`.
3536

3637
# Usage and Documentation
3738

38-
If the package is installed, PyMuPDF supports the fonts automatically. To use one, execute ``font = fitz.Font("code")``, where ``code`` is a value from the first table column below.
39+
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.
3940

40-
You can then either use the ``font`` object directly in PyMuPDF's ``TextWriter`` class, or use its buffer in the conventional `Page.insertFont()` / `Page.insertText()` / `Page.insertTextbox()` methods like this:
41+
You can then either use the ``font`` object directly in PyMuPDF's ``TextWriter`` class, or **use its buffer** in the conventional `Page.insertFont()` / `Page.insertText()` / `Page.insertTextbox()` methods like this:
4142

4243
```python
43-
xref = page.insertFont(fontname="F0", fontbuffer=font.buffer)
44+
page.insert_font(fontname="F0", fontbuffer=font.buffer)
45+
page.insert_text(point, text, fontname="F0", ...)
46+
# or similarly:
47+
page.insert_textbox(rect, text, fontname="F0", ...)
4448
```
4549

4650
For more detail consult the PyMuPDF documentation of the [Font](https://pymupdf.readthedocs.io/en/latest/font.html) class.
@@ -66,3 +70,15 @@ For more detail consult the PyMuPDF documentation of the [Font](https://pymupdf.
6670
| notosbi | Noto Sans Italic | 1.0.3 |
6771
| notosbo | Noto Sans Bold | 1.0.3 |
6872
| notosbi | Noto Sans Bold Italic | 1.0.3 |
73+
| ubuntu | Ubuntu Regular | 1.0.4 | sans-serif, for texts in Ubuntu look
74+
| ubuntubo | Ubuntu Bold | 1.0.4 |
75+
| ubuntubi | Ubuntu Bold Italic | 1.0.4 |
76+
| ubuntuit | Ubuntu Italic | 1.0.4 |
77+
| ubuntm | Ubuntu Mono Regular | 1.0.4 | mono-spaced version of Ubuntu fonts
78+
| ubuntmbo | Ubuntu Mono Bold | 1.0.4 |
79+
| ubuntmbi | Ubuntu Mono Bold Italic | 1.0.4 |
80+
| ubuntmit | Ubuntu Mono Italic | 1.0.4 |
81+
82+
# License
83+
Most of the fonts above are licensed under the SIL OFL v1.1 license, which is stored as file `LICENSE.txt` in this repository.
84+
The Ubuntu fonts are available under a similar free license, to be found here: [Ubuntu Font License](http://font.ubuntu.com/ufl/).

0 commit comments

Comments
 (0)