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

  • Smart Font Selection: Automatically prioritizes system fonts (Arial, Helvetica, Times New Roman) when available. Falls back to bundled open-source fonts (Arimo, Tinos) only when system fonts are missing. This ensures optimal performance and user preference while maintaining compatibility.
  • 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 will be Arial/Helvetica if available, otherwise 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 Primary Font (if available) Fallback Font Base Font Size Target Journals
'nature' Sans-serif Arial/Helvetica Arimo (matches Arial) 7 pt Nature, Nature Comms, Scientific Reports
'cell' Sans-serif Arial/Helvetica Arimo (matches Arial) 8 pt Cell, Molecular Cell, Neuron
'science' Sans-serif Arial/Helvetica Arimo (matches Arial) 9 pt Science, Science Advances
'ieee' Serif Times New Roman/Times 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().

🛡️ Smart Font Selection & Legal Compliance

Font Selection Strategy: scifont intelligently selects fonts based on availability:

  1. System Fonts First: If Arial, Helvetica, or Times New Roman are available on your system, they will be used automatically. This provides the best performance and respects user preferences.
  2. Automatic Fallback: If system fonts are missing (common in Docker/Linux environments), scifont automatically falls back to bundled open-source fonts (Arimo/Tinos).

Why Bundle Open-Source Fonts? 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 alone 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, as fallback fonts.

  • 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.3.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.3-py3-none-any.whl (2.6 MB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: scifont-0.1.3.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.3.tar.gz
Algorithm Hash digest
SHA256 a1b91ff2141b587b7422403d49335fcef1cc30a3eb2c24aaaa6c60d2b3d9f90c
MD5 b21b373e870e8586a85be98d1596b9e6
BLAKE2b-256 ec5fd3eced6cb7363e9008823faabcd655224a39922dd347836ea458e12c9079

See more details on using hashes here.

File details

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

File metadata

  • Download URL: scifont-0.1.3-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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 7ec8d1ff4afeff32fdc1fe670cbad82f483916d02394d3e31dc884573858e685
MD5 4d185701adcffbffeb304a4fef0ccec1
BLAKE2b-256 87563530c93e8b05b8013b9b6a0c03f0412f0b79943b39dc04c8177e382c81f4

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