Skip to main content

fontfinder

Overview

fontfinder is a Python package for finding and installing fonts for Unicode scripts. It's useful when generating documents that must specify a font family and will be viewed across multiple platforms. For now, fontfinder mostly locates fonts in the Google Noto font collection.

Font enumeration and installation is currently supported on macOS (using CoreText) and Windows (using DirectWrite).

Most functionality is provided by instantiating the FontFinder class.

Docs

See multiscript.app/fontfinder

Examples

>>> from fontfinder import FontFinder
>>> ff = FontFinder()
>>> text = 'الشمس (رمزها: ☉) هي النجم المركزي للمجموعة الشمسية.' # From Arabic Wikipedia article about the Sun
>>> ff.analyse(text)
TextInfo(main_script='Arabic', script_variant='', emoji_count=1, script_count=Counter({'Arabic': 39, 'Common': 12}))
>>> known_families = ff.find_families(text) # Available font families for the given text
>>> print(known_families)
['Noto Kufi Arabic', 'Noto Naskh Arabic', 'Noto Naskh Arabic UI', 'Noto Sans Arabic']
>>> preferred_family = ff.find_family(text) # Selects a single preferred font family for the text
>>> print(preferred_family)
Noto Naskh Arabic
>>> print(ff.installed_families(preferred_family)) # The font family is not yet installed
[]
>>> family_fonts = ff.find_family_fonts(preferred_family)
>>> print([font_info.postscript_name for font_info in family_fonts]) # The individual fonts in the family
['NotoNaskhArabic-Bold', 'NotoNaskhArabic-Medium', 'NotoNaskhArabic-Regular', 'NotoNaskhArabic-SemiBold']
>>> from tempfile import TemporaryDirectory
>>> tempdir = TemporaryDirectory()
>>> fonts_for_download = ff.find_family_fonts_to_download(preferred_family) # The indiv fonts that can be downloaded
>>> fonts_for_install = ff.download_fonts(fonts_for_download, tempdir.name) # The downloaded fonts
>>> ff.install_fonts(fonts_for_install) # Actually install each individual font
>>> print(ff.installed_families(preferred_family)) # The font family is now installed
['Noto Naskh Arabic']
>>> ff.uninstall_fonts(fonts_for_install) # Uninstall each individual font
>>> print(ff.installed_families(preferred_family)) # The font family is once again not installed
[]
>>> tempdir.cleanup()

Attribution

Parts of this library are derived from code in the FindSystemFontsFilename library by moi15moi (https://github.com/moi15moi/FindSystemFontsFilename/), under the MIT Licence.

See ACKNOWLEDGEMENTS for more detail.

Installation

pip install fontfinder

Build Instructions

Use these instructions if you’re building from the source. fontfinder has been developed on Python 3.10, but should work on other versions as well.

  1. git clone https://github.com/multiscript/fontfinder/
  2. cd fontfinder
  3. python3 -m venv venv (Create a virtual environment.)
    • On Windows: python -m venv venv
  4. source venv/bin/activate (Activate the virtual environment.)
    • In Windows cmd.exe: venv\Scripts\\activate.bat
    • In Windows powershell: .\\venv\Scripts\Activate.ps1 You may first need to run Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
  5. For development work...
    • pip install -e . (Creates an editable local install)
  6. ...or to build the package:
    • pip install build
    • python -m build

Metadata

Release files for fontfinder 0.16.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for fontfinder 0.16.1
File Size Uploaded
fontfinder-0.16.1.tar.gz 218.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for fontfinder 0.16.1
File Interpreter ABI Platform
fontfinder-0.16.1-py3-none-any.whl Python 3 none any Details

Total release size: 435.3 kB

Release files / fontfinder-0.16.1.tar.gz

Download URL fontfinder-0.16.1.tar.gz
Size 218.5 kB
Tags Source
SHA-256 checksum
How to use checksums
02bcbcdc140784c62115d8b09409bfdfe00f746b5c02267c5c67269a24b185d0
BLAKE2b-256 checksum
How to use checksums
96792a9f4ff9ff120e33de499b06270b70236b1df5cde916d1a7de72e094818d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.6

Release files / fontfinder-0.16.1-py3-none-any.whl

Download URL fontfinder-0.16.1-py3-none-any.whl
Size 216.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4d4c055a95a0ac20b388cbcb80032c3520d5b262f0d5f24d62c4c9af13e22ee5
BLAKE2b-256 checksum
How to use checksums
45551b29056e796d3dc2c474d92fca0dd285f831169ecb0ee154dee07f681bb4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.6

Release history Release notifications | RSS feed

This release

0.16.1 This release

2 release files

0.16.0

2 release files

0.15.0

2 release files

0.14.0

2 release files

0.13.0

2 release files

0.11.0

2 release files

0.10.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page