Skip to main content

A tiny font helper for applying font files to matplotlib.

Project description

matfonter

matfonter is a tiny helper package for loading a .ttf or .otf font file into matplotlib and applying it globally before plotting.

Install

Local development install

pip install -e .

PyPI install

pip install matfonter

Usage

matfonter(path_to_font, unicode_minus=False)
  • path_to_font: path to a .ttf or .otf font file
  • unicode_minus: value assigned to plt.rcParams["axes.unicode_minus"]
  • returns: the resolved matplotlib font family name
from matfonter import matfonter
import matplotlib.pyplot as plt

matfonter("/path/to/your/font.ttf", unicode_minus=False)

plt.plot([1, 2, 3], [3, 1, 4])
plt.title("Custom Font Demo")
plt.show()

Example Font

For CJK examples, a good default is Source Han Sans SC Heavy (思源黑体), which is open source under SIL Open Font License 1.1, and also easy to find out the effect - obsolutely bold.

If you only reference the font in examples, your project license can stay MIT. If you redistribute the font file with your package or repo, keep the font under its own OFL-1.1 terms and include the required license notice.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

matfonter-0.1.0.tar.gz (3.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

matfonter-0.1.0-py3-none-any.whl (3.6 kB view details)

Uploaded Python 3

File details

Details for the file matfonter-0.1.0.tar.gz.

File metadata

  • Download URL: matfonter-0.1.0.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for matfonter-0.1.0.tar.gz
Algorithm Hash digest
SHA256 f64cbd5fee3abfcde6c51b1b091b58999bf9443442e743845bed4b25d06bbfa5
MD5 276e25d39f27c186349e8fa5a793daa7
BLAKE2b-256 423fa2df1cfb8706ad19311955cd1f0aff19646c8eea35d02810ef987707c4dc

See more details on using hashes here.

File details

Details for the file matfonter-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: matfonter-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 3.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for matfonter-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 529e166cc4aa22c64b8a279cefdff9a08ae8c41bf2be8dd7aed14fa7730dee4d
MD5 ff1bb65c0c3698452557196e70b35691
BLAKE2b-256 0959d07dfbc913b1c49ef14cec866dd7a4b046c6832ce864cdff1633deb337bc

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page