Skip to main content

Force publication-quality, editable fonts in Matplotlib figures.

Project description

scifont

中文 | English

Publication-ready Matplotlib figures with editable text and journal-compliant fonts.

The Problem

As a researcher creating figures for publication, you've likely encountered these issues:

  1. Font inconsistencies across environments: Your figures look perfect on your local machine (Windows, macOS, or Linux), but when you run the same code on a server, in a Docker container, or in CI/CD pipelines, the fonts are missing. Arial and Times New Roman aren't available everywhere, causing your figures to break or look different.

  2. Uneditable text in vector graphics software: You export your figure as PDF or SVG for final editing in Adobe Illustrator or Inkscape, only to discover that the text is converted to uneditable paths. Fixing a typo or adjusting labels means redrawing the entire figure.

  3. Manual journal style configuration: Each journal has specific font and size requirements. You spend hours tweaking Matplotlib's rcParams to match Nature's guidelines, then repeat the entire process when submitting to Science or IEEE.

The Solution

scifont solves all three problems with one line of code:

import scifont
scifont.use('nature')  # That's it!

What it does:

  • ✅ Automatically uses system fonts (Arial, Helvetica, Times New Roman) when available, seamlessly falls back to metric-compatible open-source fonts (Arimo/Tinos) when system fonts are missing
  • ✅ Configures Matplotlib to export editable text in PDF/SVG files, so you can fix typos in Adobe Illustrator without redrawing
  • ✅ Provides one-line configuration for Nature, Science, Cell, and IEEE style guidelines—no more manual rcParams tweaking

🚀 Key Features

  • Smart Font Selection: Prioritizes system fonts (Arial, Helvetica, Times New Roman) when available. Automatically falls back to bundled open-source fonts (Arimo, Tinos) when system fonts are missing.

  • Metric-Compatible Fonts: We bundle Arimo and Tinos (Apache 2.0 Licensed) as alternatives to Arial and Times New Roman. They have identical character widths and spacing, so your layout stays exactly the same.

  • Editable Vector Graphics: Automatically configures Matplotlib to export PDFs as Type 42 objects and SVGs as <text> tags. Text remains editable in Adobe Illustrator, Inkscape, and CorelDRAW.

  • Journal Presets: One-line configuration for Nature, Science, Cell, and IEEE standards.

📦 Installation

pip install --upgrade scifont

Or install from source:

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

⚡ Quick Start

import matplotlib.pyplot as plt
import scifont

# Apply journal style
scifont.use('nature')

# Plot as usual
plt.figure(figsize=(4, 3))
plt.plot([1, 2, 3], [4, 5, 6], label='Data')
plt.title("Editable Text in Nature Style")
plt.xlabel("Time (s)")
plt.ylabel("Velocity (m/s)")
plt.legend()

# Save - text will be editable in Adobe Illustrator!
plt.tight_layout()
plt.savefig("figure.pdf")
plt.savefig("figure.svg")

📖 Supported Journal Styles

Style Font Family Primary Font Fallback Font Base Size Target Journals
'nature' Sans-serif Arial/Helvetica Arimo 7 pt Nature, Nature Comms, Scientific Reports
'cell' Sans-serif Arial/Helvetica Arimo 8 pt Cell, Molecular Cell, Neuron
'science' Sans-serif Arial/Helvetica Arimo 8 pt Science, Science Advances
'ieee' Serif Times New Roman/Times Tinos 8 pt IEEE Transactions, Phys. Rev. Lett.

Note: You can override any setting using plt.rcParams after calling scifont.use().

🎯 What scifont Does (and Doesn't Do)

What scifont solves:

  • ✅ Font consistency across all platforms (Windows, macOS, Linux) and environments (local machines, servers, Docker containers)
  • ✅ Editable text in PDF/SVG files—fix typos in Adobe Illustrator without redrawing
  • ✅ Journal-compliant font and size settings for major journals
  • ✅ True cross-platform compatibility—same code works everywhere

What scifont doesn't do:

  • ❌ It's not a design tool—you still need to adjust layout, colors, and aesthetics
  • ❌ It won't automatically make your figures publication-ready—you'll still need to fine-tune spacing, legends, and annotations
  • ❌ It's a configuration helper, not a replacement for manual work

Think of it as a solid foundation. One scifont.use('nature') call replaces dozens of manual rcParams tweaks, but you're still in full control to customize everything afterward.

🛡️ Why Bundle Open-Source Fonts?

Arial and Times New Roman are proprietary fonts owned by Monotype. It's illegal to bundle them in a Python package without a costly license. Also, relying on system fonts alone causes inconsistencies—a plot rendered on Windows or macOS (with Arial) looks different on Linux servers or Docker containers (without Arial).

Our solution: We bundle Arimo and Tinos (developed by Steve Matteson for Google) as fallback fonts. They're:

  • Apache License 2.0: Free to use, bundle, and distribute
  • Metric-compatible: Identical character widths and spacing to Arial and Times New Roman. No layout changes when switching fonts.

🔧 Technical Details

By default, scifont.use() applies these Matplotlib settings:

plt.rcParams['pdf.fonttype'] = 42  # Embed TrueType fonts (editable)
plt.rcParams['ps.fonttype'] = 42
plt.rcParams['svg.fonttype'] = 'none'  # Don't convert text to paths

This ensures compatibility with Adobe Illustrator, CorelDRAW, and Inkscape.

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: scifont-0.1.6.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.6.tar.gz
Algorithm Hash digest
SHA256 5f881f9c86ededc0b60f8189fbb4e582ba42e5a325652d35dffc8555a9ce73bf
MD5 5e27a598f4847dd0705b8b0ad23b907f
BLAKE2b-256 a90fc1af138ed40d6aacd3cb57afb1fe3469d0d07aad04768c3368b7cd74822a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: scifont-0.1.6-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.6-py3-none-any.whl
Algorithm Hash digest
SHA256 9e7004b123f885a6566b47277f8db8c8efaeb0121a81a9a76baa1c43a335db0f
MD5 7e1eee532d0adf2ef8019141eeea26cf
BLAKE2b-256 de3770d79ee970a212edca634500b063375c58760929c989d8b3c8f0e4119be1

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