Skip to main content

Detect, decode, and encode legacy Hindi font encodings like Walkman Chanakya, KrutiDev 010, and DevLys 010 into Unicode Devanagari.

Project description

HinLegacy logo

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.

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

hinlegacy-1.0.1.tar.gz (25.3 kB view details)

Uploaded Source

Built Distribution

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

hinlegacy-1.0.1-py3-none-any.whl (25.5 kB view details)

Uploaded Python 3

File details

Details for the file hinlegacy-1.0.1.tar.gz.

File metadata

  • Download URL: hinlegacy-1.0.1.tar.gz
  • Upload date:
  • Size: 25.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.5

File hashes

Hashes for hinlegacy-1.0.1.tar.gz
Algorithm Hash digest
SHA256 efd822cfa7c72e8185d13fa1e9900c5f1f7b9d3c2a226f97bc21f71ac8ff0bc6
MD5 8ce5a0a0d9eaf7af7e57893910efd10e
BLAKE2b-256 05c23af1222571d358a53ac5464b98ab7d88ca635ea8146c5d66c7c4071d0fdc

See more details on using hashes here.

File details

Details for the file hinlegacy-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: hinlegacy-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 25.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.5

File hashes

Hashes for hinlegacy-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8e84d53b1d304fabed3026554cc27e30557d138935037d48323d887b6a689c36
MD5 0a1ad477deefcf6f3456739c43221f04
BLAKE2b-256 be3e04eb8730271598103e5f0ceceb7658d52cb8538935deb912e386d9f55973

See more details on using hashes here.

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