Pure Python Google Fonts toolkit -- 50 fonts metadata, CSS generation, font stacks, pairings, and design systems. Zero dependencies.
Project description
fontfyi
Pure Python Google Fonts toolkit. Access 50 popular fonts metadata, generate CSS import URLs, browse 10 web-safe font stacks, and 15 curated font pairings -- all with zero dependencies.
Explore all fonts at fontfyi.com -- font explorer, font pairings, font stacks, and developer API.
Install
pip install fontfyi # Core engine (zero deps)
pip install "fontfyi[cli]" # + Command-line interface
pip install "fontfyi[mcp]" # + MCP server for AI assistants
pip install "fontfyi[api]" # + HTTP client for fontfyi.com API
pip install "fontfyi[all]" # Everything
Quick Start
from fontfyi import get_font, css_family, google_fonts_url, parse_variants
# Look up a font
font = get_font("inter")
print(font["family"]) # Inter
print(font["category"]) # sans-serif
print(font["designer"]) # Rasmus Andersson
# Parse weight variants
weights, italic = parse_variants(font["variants"])
print(weights) # [100, 200, 300, 400, 500, 600, 700, 800, 900]
print(italic) # True
# Generate CSS
print(css_family("Inter", "sans-serif"))
# 'Inter', sans-serif
print(google_fonts_url("Inter", [400, 700]))
# https://fonts.googleapis.com/css2?family=Inter:wght@400;700&display=swap
Font Pairings & Stacks
from fontfyi import (
search, popular, by_category, get_stack,
get_pairings_for, featured_pairings, FONT_STACKS,
)
# Search fonts
results = search("mono")
for f in results:
print(f"{f['family']} ({f['category']})")
# Top 10 most popular fonts
for f in popular(10):
print(f"{f['popularity_rank']}. {f['family']}")
# Font stacks (CSS-ready)
stack = get_stack("system-ui")
print(stack.stack)
# system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, ...
# Font pairings with rationale
for p in get_pairings_for("inter"):
print(f"{p.heading} + {p.body} (score: {p.score})")
print(f" {p.rationale}")
print(f" Mood: {p.mood}")
Command-Line Interface
pip install "fontfyi[cli]"
fontfyi info inter # Font metadata table
fontfyi search mono # Search fonts by name
fontfyi css inter # CSS import snippet
fontfyi pair inter # Font pairing suggestions
fontfyi popular # Top fonts by popularity
fontfyi stacks # Font stack presets
MCP Server (Claude, Cursor, Windsurf)
Add font tools to any AI assistant that supports Model Context Protocol.
pip install "fontfyi[mcp]"
Add to your claude_desktop_config.json:
{
"mcpServers": {
"fontfyi": {
"command": "python",
"args": ["-m", "fontfyi.mcp_server"]
}
}
}
Available tools: font_info, font_search, font_css, font_pairings, font_stacks, popular_fonts
REST API Client
pip install "fontfyi[api]"
from fontfyi.api import FontFYI
with FontFYI() as api:
info = api.font("inter") # GET /api/font/inter/
css = api.css("inter") # GET /api/font/inter/css/
results = api.search("mono") # GET /api/search/?q=mono
pairings = api.pairings("inter") # GET /api/pairings/inter/
stacks = api.stacks() # GET /api/font-stacks/
Full API documentation with OpenAPI spec at fontfyi.com/api/openapi.json.
API Reference
Font Data
| Function | Description |
|---|---|
get_font(slug) -> dict | None |
Look up font by slug |
search(query, limit=20) -> list[dict] |
Search fonts by name |
by_category(category) -> list[dict] |
Filter by category |
popular(limit=20) -> list[dict] |
Top fonts by popularity |
all_fonts() -> list[dict] |
All 50 fonts |
font_count() -> int |
Total font count |
CSS Utilities
| Function | Description |
|---|---|
css_family(family, category) -> str |
'Inter', sans-serif |
google_fonts_url(family, weights?) -> str |
Google Fonts CSS URL |
google_fonts_link(family, weights?) -> str |
HTML <link> tag |
google_download_url(family) -> str |
Direct download URL |
homebrew_install_cmd(family) -> str |
brew install --cask font-inter |
parse_variants(variants) -> (weights, italic) |
Parse variant strings |
weight_name(weight) -> str |
400 -> "Regular" |
Font Stacks
| Function | Description |
|---|---|
get_stack(slug) -> FontStack | None |
Get a font stack by slug |
FONT_STACKS |
All 10 curated font stacks |
Available stacks: system-ui, transitional, old-style, humanist, geometric-humanist, neo-grotesque, monospace-slab, monospace-code, industrial, rounded
Font Pairings
| Function | Description |
|---|---|
get_pairings_for(slug) -> list[FontPairing] |
Pairings containing a font |
featured_pairings() -> list[FontPairing] |
Score >= 8 pairings |
PAIRINGS |
All 15 curated pairings |
Data Types
FontStack-- NamedTuple: slug, name, description, stackFontPairing-- NamedTuple: heading, body, rationale, score, use_cases, mood
Features
- 50 Google Fonts: family, category, variants, subsets, designer, popularity rank
- CSS generation: font-family declarations, Google Fonts URLs, HTML link tags
- Weight parsing: variant strings to numeric weights with italic detection
- 10 font stacks: system-ui, transitional, humanist, neo-grotesque, monospace, and more
- 15 font pairings: Curated heading + body combinations with rationale and scores
- Homebrew commands:
brew install --cask font-{name}generator - CLI: Rich terminal output with font info, search, CSS snippets
- MCP server: 6 tools for AI assistants (Claude, Cursor, Windsurf)
- REST API client: httpx-based client for fontfyi.com API
- Zero dependencies: Core engine uses only
jsonandpathlibfrom stdlib - Type-safe: Full type annotations,
py.typedmarker (PEP 561)
FYIPedia Developer Tools
Part of the FYIPedia open-source developer tools ecosystem:
| Package | Description |
|---|---|
| colorfyi | Hex to RGB converter, WCAG contrast checker, color harmonies |
| emojifyi | Emoji encoding & metadata for 3,781 Unicode emojis |
| symbolfyi | Symbol encoder -- 11 encoding formats for any character |
| unicodefyi | Unicode character lookup -- 17 encodings + character search |
| fontfyi | Google Fonts explorer -- metadata, CSS helpers, font pairings |
| distancefyi | Haversine distance, bearing, travel times -- distancefyi.com |
| timefyi | Timezone operations, time differences -- timefyi.com |
| namefyi | Korean romanization, Five Elements -- namefyi.com |
| unitfyi | Unit conversion, 200 units, 20 categories -- unitfyi.com |
| holidayfyi | Holiday dates, Easter calculation -- holidayfyi.com |
Links
- Font Explorer -- Browse all Google Fonts
- Font Pairings -- Curated heading + body combinations
- Font Stacks -- CSS-ready font stack presets
- REST API Documentation -- Free API with OpenAPI spec
- Source Code -- MIT licensed
License
MIT
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fontfyi-0.2.0.tar.gz.
File metadata
- Download URL: fontfyi-0.2.0.tar.gz
- Upload date:
- Size: 84.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.8 {"installer":{"name":"uv","version":"0.10.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b436d2b3fa4ab079414c9aca3f65b1d7304c2de4b36af7a2847a47292c9ee684
|
|
| MD5 |
40feca09cff3e4f6e221e451f4db16b8
|
|
| BLAKE2b-256 |
c7895af2fd616404668bff4a456c534d5b812245ffda747341a2d2d44ca70814
|
File details
Details for the file fontfyi-0.2.0-py3-none-any.whl.
File metadata
- Download URL: fontfyi-0.2.0-py3-none-any.whl
- Upload date:
- Size: 20.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.8 {"installer":{"name":"uv","version":"0.10.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
54a52a6fc5309ef0100433ecac9ac286a1f11571d199fe061636244134027cd8
|
|
| MD5 |
3f236a19cebcec48205c35894f0637f8
|
|
| BLAKE2b-256 |
b952121a18c2630feb674ae0b9825bfb45b5c97409fc810f6d9f5f3d8de22e92
|