Metadata-Version: 2.5
Name: sinhala-legacy-fonts
Version: 0.1.0
Summary: Convert FM-family legacy (non-Unicode) Sinhala font text to Unicode
Project-URL: Repository, https://github.com/e4c5/sinhala-legacy-fonts
Project-URL: Issues, https://github.com/e4c5/sinhala-legacy-fonts/issues
Author: Raditha Dissanayake
License-Expression: MIT
License-File: LICENSE
Keywords: converter,fm,fmabhaya,font,legacy,sinhala,unicode
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Text Processing
Requires-Python: >=3.10
Description-Content-Type: text/markdown

# sinhala-legacy-fonts

Convert text stored in the **FM family** of legacy, non-Unicode Sinhala
fonts (`FMAbhaya`, `FMAbabld` and related) to Unicode — including the
visual-order → logical-order reordering of pre-base vowel signs.

Pure Python, standard library only, Python 3.10+.

```python
from sinhala_legacy_fonts import sinhala_fm_to_unicode, encoding_for_font

encoding_for_font("ABCDEF+FMAbhaya")  # "fm"  (PDF subset prefix is stripped)
encoding_for_font("IskoolaPota")  # None  (already-Unicode font)
encoding_for_font("DL-Manel")  # None  (different encoding — not converted)

sinhala_fm_to_unicode("fmda")  # "පෝ"
sinhala_fm_to_unicode("fl")  # "කෙ"
```

`sinhala_fm_to_unicode` is a pure function: no file, font, PDF or network
access. Glyph codes it does not recognise pass through unchanged.

## Supported fonts

Only the **FM family** is supported. `encoding_for_font(name)` returns
`"fm"` when the (base) font name starts with `FM`, `None` otherwise.
`FMAbhaya` and `FMAbabld` are verified; other `FM*` fonts are assumed to
share the glyph layout — treat them as probable, not proven. Text in any
other legacy encoding (e.g. DL fonts, Kaputa) will convert *wrongly*, so
always check the font name first. See
[docs/supported-fonts.md](docs/supported-fonts.md).

## The encoding, briefly

FM stores each Sinhala letter at a fixed keyboard code point. In
particular the pre-base vowel sign `f` (ෙ) is encoded **before** its
consonant, mirroring visual order, while Unicode orders consonant first,
sign after — so conversion must reorder clusters rather than substitute
glyph for glyph. See [docs/encoding.md](docs/encoding.md).

## Limitations

- Only the FM family (above) is supported.
- A handful of glyph codes are unverified (marked `UNVERIFIED` in the
  table source and listed in [docs/supported-fonts.md](docs/supported-fonts.md));
  they may change in a future release.
- Conversion can leave residual Latin glyphs or produce incorrect output
  on malformed input; it is not a validator.

## Acknowledgements

Originally written for [MurphyLearn](https://murphylearn.com).

See also [Pandukabhaya](https://pypi.org/project/pandukabhaya/),
[Open-SL sinhala-unicode-converter](https://github.com/Open-SL) and the
UCSC LTRL work they draw on — independent implementations used as
cross-references during development, not sources.

## Licence

[MIT](LICENSE)
