Skip to content

Commit

Permalink
upload v1.0.4
Browse files Browse the repository at this point in the history
  • Loading branch information
JorjMcKie committed Sep 19, 2021
1 parent bc7a4e1 commit 37348f8
Show file tree
Hide file tree
Showing 12 changed files with 16,357 additions and 32 deletions.
58 changes: 35 additions & 23 deletions PKG-INFO
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Metadata-Version: 1.1
Name: pymupdf_fonts
Version: 1.0.3
Version: 1.0.4
Author: Jorj McKie
Author-email: Jorj.x.mckie@outlook.de
License: SIL OFL V1.1
Expand All @@ -10,39 +10,51 @@ Home-page: https://github.com/pymupdf/pymupdf_fonts
Download-url: https://github.com/pymupdf/pymupdf_fonts
Summary: pymupdf_fonts is a collection of fonts to be used by PyMuPDF
Description:
Release date: March 10, 2021

Release date: September 19, 2021
Author
======

* Jorj X. McKie

Introduction
============

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: (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.

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.

Currently the following fonts made by Mozilla are provided:
* **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).
* **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.
* **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.


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.

Currently the following fonts are provided:

* **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).
* **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.
* **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.
* **NOTO Sans** -- Google font family similar to Helvetica. Supports Regular, Bold, Italic and Bold-Italic.
* **NOTO Music** -- Google font for musical symbols.
* **NOTO SANS Math** -- Google font for mathematical symbols.
* **NOTO Symbols** and **NOTO Symbols2** -- Google symbol fonts.
* **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.

Installation
============

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.

pymupdf-fonts is a pure Python package provided as a wheel. As such it is Python version independent.
Usage and Documentation
========================

Using the fonts is documented in PyMuPDF.


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".

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())``.

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).

License
========================

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/`_.

Classifier: Development Status :: 5 - Production/Stable
Classifier: Environment :: Console
Expand Down
32 changes: 24 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# pymupdf-fonts
Collection of optional fonts for PyMuPDF

Release date: July 31, 2020
Release date: September 19, 2021

# Author

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

1. keep the PyMuPDF binary module size within reasonable limits by not adding more fonts to it, and
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.
2. enable the inclusion of arbitrary fonts that are not contained in the MuPDF library. We also may extend this repository with selected fonts.

Currently the following fonts are provided:
* **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).
* **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).
* **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.
* **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.
* **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.
* **Noto Sans Math Regular** a NOTO font from Google providing mathematical symbols.
* **Noto Music Regular** a NOTO font from Google providing musical symbols.
* **Noto Sans Symbols Regular** a Google NOTO replacement for the Base-14 Symbol font.
* **Noto Sans Symbols2 Regular** an extension for the previous.
* **Noto Sans** a Google NOTO font family replacement for Helvetica / Arial, which support all four weights regular, bold, italics and bold-italics.
* **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.


# Installation

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**.
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`.

# Usage and Documentation

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.
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.insertFont()` / `Page.insertText()` / `Page.insertTextbox()` methods like this:
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:

```python
xref = page.insertFont(fontname="F0", fontbuffer=font.buffer)
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](https://pymupdf.readthedocs.io/en/latest/font.html) class.
Expand All @@ -66,3 +70,15 @@ For more detail consult the PyMuPDF documentation of the [Font](https://pymupdf.
| 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 |

# License
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](http://font.ubuntu.com/ufl/).
Loading

0 comments on commit 37348f8

Please sign in to comment.