HinLegacy
Detect, decode, and encode legacy Hindi font text for modern AI, archival, and document-processing pipelines.
Walkman Chanakya 905 · KrutiDev 010 · DevLys 010
Overview
A large amount of Hindi content across institutions, offices, schools, publishers, archived records, and long-running desktop publishing workflows still exists in legacy font encodings such as KrutiDev, DevLys, and Chanakya.
These documents may appear visually correct on screen, but internally they are often stored as font-dependent glyph sequences instead of proper Unicode Devanagari text.
That creates a serious problem in the modern text-processing stack.
Search, indexing, embeddings, semantic retrieval, NLP pipelines, entity extraction, RAG systems, and LLM-based processing all work best when the underlying text is valid Unicode. Legacy Hindi encodings break that assumption and make otherwise valuable document collections hard to search, reuse, normalize, or understand programmatically.
OCR is often the right tool for scanned images and paper-first archives. But when the source is already digital text in a legacy encoding, OCR can add unnecessary compute cost, introduce avoidable recognition errors, and reduce pipeline reliability.
HinLegacy is built for that gap.
Instead of treating legacy Hindi text as an image problem, HinLegacy treats it as an encoding-conversion problem.
Why HinLegacy
HinLegacy helps modern systems work with old Hindi text by providing:
- 🔍 Font detection for supported legacy Hindi encodings
- 🔁 Direct decoding from legacy font text to Unicode Devanagari
- 📝 Encoding from Unicode back into supported legacy fonts
- ⚙️ A Python API for integration into applications and pipelines
- 💻 A CLI for direct terminal usage
- 🧠 A practical bridge between legacy Hindi documents and AI-era processing systems
This makes it useful for:
- RAG pipelines over Hindi archives
- Government and educational document modernization
- Search indexing over legacy corpora
- Vector database ingestion
- Hindi NLP preprocessing
- ETL and document cleanup workflows
- Internal tooling for archive migration
Supported Fonts
HinLegacy currently supports:
- Walkman Chanakya 905
- KrutiDev 010
- DevLys 010
Installation
Install from PyPI
pip install hinlegacy
Install for local development
git clone https://github.com/satvikmishra44/hinlegacy.git
cd hinlegacy
pip install -e .
Quick Start
Python API
from hinlegacy import detect, decode, encode, convert
legacy_text = "your legacy text here"
result = detect(legacy_text)
print(result.font_slug)
print(result.confidence)
print(result.method)
unicode_text = decode(legacy_text, "krutidev_010")
print(unicode_text)
encoded_text = encode("भारत", "devlys_010")
print(encoded_text)
converted = convert(legacy_text)
print(converted.unicode_text)
print(converted.detected_font)
print(converted.confidence)
print(converted.detection_method)
CLI
hinlegacy detect "legacy text here"
hinlegacy decode "legacy text here" --font krutidev_010
hinlegacy encode "भारत" --font devlys_010
hinlegacy convert "legacy text here"
hinlegacy list-fonts
CLI Commands
Detect the font
hinlegacy detect "legacy text here"
Output includes:
- detected font slug
- confidence score
- detection method
Decode legacy text into Unicode
hinlegacy decode "legacy text here" --font krutidev_010
Encode Unicode text into a legacy font
hinlegacy encode "भारत एक सुंदर देश है" --font walkman_chanakya_905
Convert with auto-detection
hinlegacy convert "legacy text here"
List supported fonts
hinlegacy list-fonts
Python API Reference
detect(text: str) -> DetectionResult
Detects which supported legacy Hindi font is used in the given text.
decode(text: str, font: str) -> str
Decodes legacy Hindi text into Unicode Devanagari using the specified font.
encode(text: str, font: str) -> str
Encodes Unicode Hindi text into the specified legacy font.
convert(text: str, font: str | None = None) -> ConversionResult
Converts legacy Hindi text into Unicode.
If font is provided, HinLegacy decodes directly using that font.
If font is omitted, HinLegacy first detects the font and then decodes it.
Result Models
DetectionResult
@dataclass
class DetectionResult:
font_slug: str
confidence: float
method: str
ConversionResult
@dataclass
class ConversionResult:
unicode_text: str
detected_font: str
confidence: float
detection_method: str
Example Workflows
1. Detect and decode legacy text
from hinlegacy import convert
result = convert("legacy text here")
print(result.unicode_text)
print(result.detected_font)
2. Decode when the font is already known
from hinlegacy import decode
text = decode("legacy text here", "devlys_010")
print(text)
3. Encode Unicode text for legacy-system compatibility
from hinlegacy import encode
legacy_text = encode("कृपया नाम लिखिए", "krutidev_010")
print(legacy_text)
4. Use in a preprocessing pipeline
from hinlegacy import convert
def normalize_legacy_hindi(text: str) -> str:
result = convert(text)
return result.unicode_text
Use Cases
- 📚 Digitizing Hindi educational content
- 🏛️ Modernizing administrative and archival records
- 🔍 Making legacy Hindi corpora searchable
- 🧠 Preparing Hindi text for embeddings and retrieval
- 🗂️ Converting legacy text before RAG ingestion
- 🧪 Cleaning text for Hindi NLP pipelines
- 📄 Converting old DTP-generated content into reusable Unicode text
Project Structure
src/hinlegacy/
├── cli/
├── decoder/
├── detector/
├── api.py
├── models.py
├── exceptions.py
├── __init__.py
└── __main__.py
Development
Run tests
pytest -v
Build the package
python -m build
Check package metadata
python -m twine check dist/*
Run the CLI locally
python -m hinlegacy --help
Release Workflow
A typical release workflow looks like this:
pytest -v
python -m build
python -m twine check dist/*
Then test installation from the built artifacts:
pip install --force-reinstall dist/*.whl
And verify:
hinlegacy --help
hinlegacy list-fonts
Limitations
- Detection is currently heuristic-based and may be less reliable on very short or ambiguous text samples.
- Unicode output may differ in some visually equivalent Hindi forms depending on normalization and font-specific mapping choices.
- OCR-based scanned image extraction is outside the scope of HinLegacy; the package is designed for machine-readable legacy text.
Roadmap
- Improved detection heuristics using broader sample corpora
- File-based batch conversion
- Structured JSON CLI output
- Expanded evaluation suite
- Additional legacy Hindi font support
- Better normalization utilities for Unicode output comparison
Contributing
Contributions are welcome, especially in:
- additional font support
- improved detection heuristics
- test corpus creation
- CLI enhancements
- documentation improvements
- OCR integrations
A good contribution workflow:
git clone https://github.com/satvikmishra44/hinlegacy.git
cd hinlegacy
pip install -e .
pytest -v
License
MIT
Add the full MIT license text in the LICENSE file at the repository root.
Vision
Legacy Hindi text is often not an OCR problem.
It is an encoding problem.
HinLegacy exists to help modern software systems understand, normalize, and unlock that text for the era of AI, search, retrieval, and reusable structured knowledge.
Metadata
Release files for hinlegacy 1.0.1
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 |
|---|---|---|---|---|
| hinlegacy-1.0.1.tar.gz | 25.3 kB | Without provenance | Details for hinlegacy-1.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| hinlegacy-1.0.1-py3-none-any.whl | Python 3 | none | any | Details for hinlegacy-1.0.1-py3-none-any.whl |
Total release size: 50.7 kB
Release files / hinlegacy-1.0.1.tar.gz
| Download URL | hinlegacy-1.0.1.tar.gz |
|---|---|
| Size | 25.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
efd822cfa7c72e8185d13fa1e9900c5f1f7b9d3c2a226f97bc21f71ac8ff0bc6
|
|
BLAKE2b-256 checksum How to use checksums |
05c23af1222571d358a53ac5464b98ab7d88ca635ea8146c5d66c7c4071d0fdc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.5
|
Release files / hinlegacy-1.0.1-py3-none-any.whl
| Download URL | hinlegacy-1.0.1-py3-none-any.whl |
|---|---|
| Size | 25.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8e84d53b1d304fabed3026554cc27e30557d138935037d48323d887b6a689c36
|
|
BLAKE2b-256 checksum How to use checksums |
be3e04eb8730271598103e5f0ceceb7658d52cb8538935deb912e386d9f55973
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.5
|
Security for hinlegacy 1.0.1
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.