Skip to main content

Force publication-quality, editable fonts in Matplotlib figures.

Project description

scifont

Professional, Reproducible, and Editable Figures for Scientific Publishing.

scifont is a lightweight Python library designed to solve the two most persistent headaches in scientific visualization with Matplotlib:

  1. Missing Fonts in Docker/Linux: "Arial" or "Times New Roman" are often missing in CI/CD environments or Linux servers, causing plots to fallback to default fonts.
  2. Non-Editable Text: Default Matplotlib settings often export text as paths (shapes), making it impossible to correct typos or adjust formatting in Adobe Illustrator or Inkscape.

🚀 Key Features

  • Bundled Open-Source Fonts: We ship with Arimo and Tinos (Apache 2.0 Licensed). These are metric-compatible alternatives to Arial and Times New Roman. They are legally safe to distribute and use anywhere.
  • Metric-Compatible: Arimo has the exact same character widths and spacing as Arial. Tinos matches Times New Roman. Your layout will remain identical to the proprietary versions.
  • Editable Vector Graphics: Automatically configures Matplotlib to export PDFs as Type 42 objects and SVGs as <text> tags. Text remains editable in downstream vector software.
  • Journal Presets: One-line configuration for Nature, Science, Cell, and IEEE standards.

📦 Installation

pip install scifont

(Or if installing from source)

git clone https://github.com/studentiz/scifont.git
cd scifont
pip install .

⚡ Quick Start

Simply import scifont and select your target journal style at the start of your script.

import matplotlib.pyplot as plt
import scifont

# 1. Apply style (e.g., 'nature' for Life Sciences, 'ieee' for Engineering)
scifont.use('nature')

# 2. Plot as usual
plt.figure(figsize=(4, 3))
plt.plot([1, 2, 3], [4, 5, 6], label='Data')

# The font is now Arimo (Arial-compatible)
plt.title("Editable Text in Nature Style")
plt.xlabel("Time (s)")
plt.ylabel("Velocity (m/s)")
plt.legend()

# 3. Save
# The output PDF/SVG will have editable text!
plt.tight_layout()
plt.savefig("figure.pdf")
plt.savefig("figure.svg")

📖 Supported Journal Styles

scifont adjusts font families, sizes, and line widths according to specific journal guidelines (2025 standards).

Style Argument Target Font Family Open-Source Font Used Base Font Size Target Journals
'nature' Sans-serif Arimo (matches Arial) 7 pt Nature, Nature Comms, Scientific Reports
'cell' Sans-serif Arimo (matches Arial) 8 pt Cell, Molecular Cell, Neuron
'science' Sans-serif Arimo (matches Arial) 9 pt Science, Science Advances
'ieee' Serif Tinos (matches Times New Roman) 8 pt IEEE Transactions, Phys. Rev. Lett.

Note: You can override any setting (e.g., font size) using standard plt.rcParams after calling scifont.use().

🛡️ Why Open Source Fonts? (The Legal Aspect)

Many researchers are unaware that Arial and Times New Roman are proprietary fonts owned by Monotype.

  1. Distribution: It is illegal to bundle arial.ttf inside a Python package and distribute it without a costly license.
  2. Reproducibility: Reliance on system fonts leads to inconsistencies. A plot rendered on macOS (with Arial) looks different on Ubuntu (without Arial).

Our Solution: We bundle Arimo and Tinos, developed by Steve Matteson for Google.

  • License: Apache License 2.0. You can use, bundle, and distribute them freely.
  • Compatibility: They are designed to be Metric-Compatible with Arial and Times New Roman. This means if you replace Arial with Arimo, the text takes up the exact same space. No line breaks will change; no labels will be cut off.

🔧 Editable Text (Vector Graphics)

By default, scifont.use() applies the following hidden Matplotlib settings to ensure compatibility with Adobe Illustrator, CorelDRAW, and Inkscape:

plt.rcParams['pdf.fonttype'] = 42  # Embbed TrueType fonts (editable)
plt.rcParams['ps.fonttype'] = 42
plt.rcParams['svg.fonttype'] = 'none' # Do not convert text to path

License

The scifont code is distributed under the MIT License. The bundled fonts (Arimo and Tinos) are distributed under the Apache License, Version 2.0.

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

scifont-0.1.2.tar.gz (2.6 MB view details)

Uploaded Source

Built Distribution

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

scifont-0.1.2-py3-none-any.whl (2.6 MB view details)

Uploaded Python 3

File details

Details for the file scifont-0.1.2.tar.gz.

File metadata

  • Download URL: scifont-0.1.2.tar.gz
  • Upload date:
  • Size: 2.6 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.2

File hashes

Hashes for scifont-0.1.2.tar.gz
Algorithm Hash digest
SHA256 4c0eca7603ca3cd4146e18376a455ba967cd13a6ceecff8fcc201ef7616e22c3
MD5 5221f32ef06830b19d919e320fcac9d6
BLAKE2b-256 83f1e30557859a2e17c7dc2c277e652ba4bd6869f3c787f5b95d250e042e1f81

See more details on using hashes here.

File details

Details for the file scifont-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: scifont-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 2.6 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.2

File hashes

Hashes for scifont-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 783819d95cf1c6d9c31219a2983ce47a265aafabc9d47d2994216367a91e2bc2
MD5 70fff3061748bd9fdb0db53829e26eee
BLAKE2b-256 0a052ef481c0c2080e37f8a482e3f1c603094675b261a4a317ec8dacec84ad6a

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