FontIdent 🔤
Identify and use the font of any text in .doc, .docx, .odt, .rtf,
.pdf, and raster images (.png, .jpg, .gif, .bmp, .webp, .tiff).
A single toolkit that ships as:
- A GitHub-ready Python library + CLI (
fontident) - A drop-in REST API (FastAPI → deploy to RapidAPI or any ASGI host)
- A Streamlit web app (publishable to an app marketplace)
What it does
| Capability | Digital documents (DOCX/PDF/ODT/RTF) | Raster images (PNG/JPG/GIF/...) |
|---|---|---|
| Identify font | Reads embedded font files + per-run font metadata (exact) | Hybrid offline-first + online-fallback matching (approximate) |
| Use the font | Renders the extracted text back with the matched/embedded font | OCRs the text and renders it back with the identified font |
Three building blocks:
extract— Pull text runs (each with font name/size/weight/style) and embedded font files out of digital documents.identify— Auto-detect which format a file is, then identify the fonts in it (document metadata or image matching).recreate— Take the text + identified font and render a new image with that font applied.
Install
# Option A: install from this repo (editable)
pip install -e .
# Core runtime deps: pillow, numpy, requests, pymupdf, python-docx
Optional extras:
pip install -e ".[api]" # fastapi + uvicorn for the REST server
pip install -e ".[app]" # streamlit for the web app
pip install -e ".[identify]" # pytesseract for OCR-based recreation
pip install -e ".[dev]" # pytest for running the tests
OCR note: image recreation uses
pytesseract, which requires thetesseractbinary:apt-get install tesseract-ocr
Usage
1. Command line
# Identify fonts in any supported file
fontident identify report.pdf
fontident identify scanned.png --hint "SAMPLE" --top 5
fontident identify notes.docx --json
# Extract text runs + embedded fonts from a document
fontident extract report.pdf
# Recreate the file's text using its identified font
fontident recreate scanned.png -o recreated.png
# Run the HTTP API server
fontident serve --port 8000
2. As a Python library
from fontident import FontIdent, identify_text, extract_document
engine = FontIdent()
# Identify fonts in an image (offline-first; online fallback if API key set)
analysis = engine.identify("poster.png", text_hint="GRAND OPENING")
for run in analysis.runs:
print(run.font.name, run.font.score, run.font.source)
# Extract exact font metadata from a digital document
doc = extract_document("resume.pdf")
for run in doc.runs:
print(run.text, "→", run.font.name, run.font.weight, run.size)
# Recreate the text with the identified font
from fontident.recreate import recreate_text
out = recreate_text("poster.png", output="recreated.png")
3. REST API (RapidAPI-ready)
Start the server:
uvicorn fontident.web.api:app --host 0.0.0.0 --port 8000
Or via the CLI: fontident serve.
curl -s -X POST http://localhost:8000/identify \
-F "file=@poster.png" -F "hint=GRAND OPENING" -F "top=3"
curl -s -X POST http://localhost:8000/extract \
-F "file=@resume.pdf"
curl -s -X POST http://localhost:8000/recreate \
-F "file=@poster.png" -o recreated.png
Endpoints: POST /identify, POST /extract, POST /recreate, GET /health,
GET /schemas (publish metadata). Interactive docs at /docs.
To publish on RapidAPI, wrap this ASGI app in a RapidAPI endpoint function
(see examples/rapidapi_handler.py) that passes uploaded files to the same
/identify logic.
4. Streamlit web app (marketplace)
streamlit run fontident/web/app.py
Upload a file, see the identified fonts, and download the recreated PNG.
How the identification works
Digital documents (exact)
- DOCX / DOC —
python-docxreads per-run font metadata; the OOXML zip is additionally scanned for embedded font files underword/fonts/. - PDF —
pymupdfextracts text spans (with font + size + color) and the actual embedded font data viapage.get_fonts()/doc.extract_font(). - ODT / RTF / TXT — best-effort style/font-table parsing.
Images (hybrid)
- Offline (default): The image is binarized and split into per-character
glyphs. Each candidate font from a local catalog (system font dirs, or a
catalog_diryou pass) renders the same characters and the glyph shapes are compared with normalized cross-correlation. Fully offline, no API cost. - Online fallback: If the offline score is too low (or you want more coverage) and an API key is configured, the image is sent to Adobe/MyFonts WhatTheFont (or a RapidAPI WhatTheFont wrapper) and the returned matches are merged in.
Configure the online backend with FONTIDENT_API_KEY / ADOBE_WTF_API_KEY
or the api_key= parameter.
Project layout
fontident/
fontident/
__init__.py # public API: FontIdent, identify_text, extract_document, ...
io/
__init__.py # file-type detection
document.py # DOCX/PDF/ODT/RTF/TXT extractors + embedded fonts
identify/
_offline.py # template-matching image font identifier + catalog
_online.py # WhatTheFont / RapidAPI online fallback
recreate/
__init__.py # OCR + rendering text with an identified font
cli/main.py # `fontident` command line
web/
api.py # FastAPI (RapidAPI-ready)
app.py # Streamlit web app
tests/ # pytest suite (+ fixture generators)
examples/rapidapi_handler.py
pyproject.toml
README.md
LICENSE
Roadmap / ideas
- Swap the offline matcher for a deep-learning glyph-embedding model (e.g.
fontmatcher) for higher image accuracy. - Extract font files to real
.ttf/.otfon disk from embedded document data (currently exposed inanalysis.embedded_fonts[*]['data']). - Add PDF→searchable-PDF (OCR) output.
- Multi-line image segmentation improvements.
License
MIT — see LICENSE.
Metadata
Release files for fontident 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| fontident-0.1.0.tar.gz | 25.0 kB | Without provenance | Details for fontident-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| fontident-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for fontident-0.1.0-py3-none-any.whl |
Total release size: 50.0 kB
Release files / fontident-0.1.0.tar.gz
| Download URL | fontident-0.1.0.tar.gz |
|---|---|
| Size | 25.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0ac410dc664b3bc7e9d6d7467258d17070c91e995dfdf0d8d8a790658b5a5a03
|
|
BLAKE2b-256 checksum How to use checksums |
7ec44c3577ab987c898db5ca4109b0f01f824a69879f62723c3c11f4633fd200
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|
Release files / fontident-0.1.0-py3-none-any.whl
| Download URL | fontident-0.1.0-py3-none-any.whl |
|---|---|
| Size | 25.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5aa9eff6a30fdd34ba7aabdc15df5a61d1f57111930b63493c72b03956c56bec
|
|
BLAKE2b-256 checksum How to use checksums |
a2928505887d9078d4683525cbb7efeb5cb6555f9a323211527723794d92a354
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|
Security for fontident 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.