Skip to content

Legacy fonts

legacy

Convert text typed in legacy 8-bit Odia fonts to Unicode Odia.

openodia.legacy needs a release newer than 0.2.0: import openodia.legacy fails on 0.2.0.

decode turns the bytes of text typed in an 8-bit Odia font into a string of keystroke characters. Each defined byte uses cp1252. The five bytes that codec leaves undefined, 0x81, 0x8D, 0x8F, 0x90 and 0x9D, stay as those code points.

to_unicode converts those keystrokes to NFC Unicode Odia. SUPPORTED_FONTS is ("ORTTSarala",). Output is NFC, so ଡ଼ is consonant plus nukta.

After the glyph table, to_unicode rebuilds each syllable in Unicode order: reph, base consonant, subjoined forms in the order typed, vowel sign, then nasal or visarga. A reph, vowel sign, nasal or visarga typed before a subjoined form gives the same output as typed after it (ÒLÕÔÍ and ÒLÔÍÕ both give କ୍ୟ୍ରେଂ). A reph typed in a syllable with no base consonant stays where it was typed. The left matra Ò, typed before the consonant, joins its right half ß, × or Ð into ୈ, ୌ or ୋ wherever that half is typed in the syllable (ÒLàÔß and ÒLÔßà both give ର୍କ୍ୟୈ). Only the first right half joins it, and a later one stays as typed (ÒLÐß gives କୋß). A second Ò in the same syllable gives େ after the joined sign (ÒLÒÐ gives କୋେ). A second reph in the same syllable is dropped (Làà gives ର୍କ). Nasals and visarga keep the order typed (LÓÕ gives କଃଂ). A nukta, Ï or a Unicode ଼, goes right after the consonant typed last before it in the same syllable, ahead of any halant or zero-width joiner, also when a vowel sign, nasal, visarga or reph is typed in between (XÐÏ and XÏÐ both give ଡ଼ା). In a syllable with no consonant, a nukta goes ahead of the vowel signs. ú typed after କ, ସ or ପ puts a half ta before that consonant (DLúf gives ଉତ୍କଳ). A run of numeric separators all convert (1Ð2Ð3 gives ୧|୨|୩).

The ORTTSarala glyph table and the ú half-ta rule come from the OdiaWikimedia ORTT-Sarala converter, https://github.com/OdiaWikimedia/Converter.

Examples:

>>> from openodia import legacy
>>> legacy.decode(b"JX\xcf\x85")
'JXÏ…'
>>> legacy.decode(b"\x8d")
'\x8d'
>>> legacy.to_unicode(legacy.decode(b"JX\xcf\xdeA"), font="ORTTSarala")
'ଓଡ଼ିଆ'

to_unicode

to_unicode(text: str, font: str) -> str

Convert keystrokes typed in a legacy 8-bit Odia font to NFC Unicode Odia.

text is the output of decode. font is a name in SUPPORTED_FONTS.

Raises:

Type Description
TypeError

text is not str.

ValueError

font is not in SUPPORTED_FONTS.

decode

decode(data: bytes) -> str

Decode legacy font bytes into keystroke characters.

Defined bytes use cp1252. The five bytes that codec leaves undefined, 0x81, 0x8D, 0x8F, 0x90 and 0x9D, stay as those code points.

Raises:

Type Description
TypeError

data is not bytes or bytearray.