Skip to main content

Python bindings to fontconfig

Project description

fontconfig-py

PyPI version Docs status

Python bindings to fontconfig based on Cython.

What is fontconfig? Fontconfig is a library for configuring and customizing font access on Unix-based systems. It helps applications locate installed fonts and select the best matching font based on criteria like family name, weight, slant, and language support. Instead of hardcoding font paths, applications use fontconfig to query the system's font database.

Currently, Linux and macOS are supported.

Install

Install from PyPI:

pip install fontconfig-py

Usage

Finding the best matching font

Use fontconfig.match() to find the single best font matching your criteria:

import fontconfig

# Find the best Arial font
font = fontconfig.match(":family=Arial:weight=200")
if font:
    print(font["family"], font["file"])

# Or using a properties dict
font = fontconfig.match(properties={"family": "Arial", "weight": 200})

Listing all matching fonts

Use fontconfig.list() to get all fonts matching a pattern:

import fontconfig

# List all English fonts
fonts = fontconfig.list(":lang=en", select=("family", "file"))
for font in fonts:
    print(font["family"], font["file"])

# List all available fonts
all_fonts = fontconfig.list()

Getting sorted font results

Use fontconfig.sort() to get fonts sorted by match quality:

import fontconfig

# Get Arial fonts sorted by match quality
fonts = fontconfig.sort(":family=Arial")
for font in fonts[:5]:  # Top 5 matches
    print(font["family"], font["file"])

Documentation

For detailed API documentation and advanced usage, visit fontconfig-py.readthedocs.io.

Features

This package offers several advantages over other fontconfig wrappers:

  • Cython-based wrapper - High performance with Pythonic API
  • Statically linked binary wheels - No runtime dependencies on fontconfig or freetype
  • Cross-platform support - Linux and macOS wheels available
  • Modern high-level API - Simple match(), list(), and sort() functions
  • Continuous integration - Automated PyPI releases and testing
  • MIT license - Permissive licensing

Other Python fontconfig wrappers

Contributing

Contributions are welcome! Please see our Contributing Guidelines for details on:

  • Setting up the development environment
  • Running tests and code quality checks
  • Submitting pull requests
  • Code of conduct

For security vulnerabilities, please see our Security Policy.

License

This project is distributed under MIT license.

The binary wheels bundle fontconfig and freetype, which are distributed under their respective licenses. See NOTICE for details.

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

fontconfig_py-1.0.1-cp310-abi3-musllinux_1_2_x86_64.whl (913.9 kB view details)

Uploaded CPython 3.10+musllinux: musl 1.2+ x86-64

fontconfig_py-1.0.1-cp310-abi3-musllinux_1_2_aarch64.whl (904.4 kB view details)

Uploaded CPython 3.10+musllinux: musl 1.2+ ARM64

fontconfig_py-1.0.1-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl (841.8 kB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ x86-64manylinux: glibc 2.28+ x86-64

fontconfig_py-1.0.1-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl (842.2 kB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ ARM64manylinux: glibc 2.28+ ARM64

fontconfig_py-1.0.1-cp310-abi3-macosx_10_9_universal2.whl (1.4 MB view details)

Uploaded CPython 3.10+macOS 10.9+ universal2 (ARM64, x86-64)

File details

Details for the file fontconfig_py-1.0.1-cp310-abi3-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for fontconfig_py-1.0.1-cp310-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 25648e376da1bd503c1285feb406943b189cc2026a233bd8de2e5d34be61c520
MD5 73a5b8c435f7cd56a24b67ba21d9cdd8
BLAKE2b-256 8cee955cdde98562159ad353a001251d92ae09e80401973cfca988b7a7fe7de9

See more details on using hashes here.

Provenance

The following attestation bundles were made for fontconfig_py-1.0.1-cp310-abi3-musllinux_1_2_x86_64.whl:

Publisher: wheels.yaml on kyamagu/fontconfig-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fontconfig_py-1.0.1-cp310-abi3-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for fontconfig_py-1.0.1-cp310-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 79c7e9025fc8f2c4eb3369c64d177f612792ef06d0f9042b16d7bc459a1f5074
MD5 2747f383c9e5ee56c280b7a4b6cb1321
BLAKE2b-256 03d370ce5ffbdaba3e53b33e27afa0be8df01e0ab92a89668e56491c75612bb7

See more details on using hashes here.

Provenance

The following attestation bundles were made for fontconfig_py-1.0.1-cp310-abi3-musllinux_1_2_aarch64.whl:

Publisher: wheels.yaml on kyamagu/fontconfig-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fontconfig_py-1.0.1-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for fontconfig_py-1.0.1-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 4d405ed7ad3766a4a343d6667ceb499d903a5a63a633313fdf431311d819f3cd
MD5 d8a36e873d700da9592ca14c865aaa10
BLAKE2b-256 abcb7eb9573fe8aa991ea3fce804c85f61cb57cc9be5a15979866dd8ac9e5011

See more details on using hashes here.

Provenance

The following attestation bundles were made for fontconfig_py-1.0.1-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl:

Publisher: wheels.yaml on kyamagu/fontconfig-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fontconfig_py-1.0.1-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for fontconfig_py-1.0.1-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 e5e4f23fdaed3d2bdc20a0b2f4402babe9ed37b949d3fdebe4c0387a4ea02359
MD5 e458e84a561b72f68922bad51c318303
BLAKE2b-256 093c272faeb1d59ba24bbaa2ee733b54dfb6941901026451d38d38ff7676496a

See more details on using hashes here.

Provenance

The following attestation bundles were made for fontconfig_py-1.0.1-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl:

Publisher: wheels.yaml on kyamagu/fontconfig-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fontconfig_py-1.0.1-cp310-abi3-macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for fontconfig_py-1.0.1-cp310-abi3-macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 b6f79ae351f38aade0883a01e739aaee328bf2943ab73ba17b403f9e5cd067d8
MD5 11b8c8adb461f7ac9dd1b83683d66e63
BLAKE2b-256 6e8730fa0c484172f08187c0cca9125bf8733ca769c6f2bff4520deeda075dda

See more details on using hashes here.

Provenance

The following attestation bundles were made for fontconfig_py-1.0.1-cp310-abi3-macosx_10_9_universal2.whl:

Publisher: wheels.yaml on kyamagu/fontconfig-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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