Skip to content

Unicode Fonts and Legacy Indic

SIDHARTH SINGH edited this page Dec 3, 2026 · 1 revision

Unicode 16, Fonts & Legacy Hindi Conversion

Indian multilingual billing, regional municipal portals, and Arabic RTL layouts often break silently on headless Linux containers where system fonts only ship basic Latin glyphs.

Bundled Fonts & Intelligent Fallback

ONEX bundles 7 SIL Open Font License Noto TTF files:

  • NotoSans-Regular.ttf / NotoSans-Bold.ttf
  • NotoSansDevanagari-Regular.ttf / NotoSansDevanagari-Bold.ttf
  • NotoSansBengali-Regular.ttf
  • NotoSansTamil-Regular.ttf
  • NotoSansArabic-Regular.ttf

Notice two intentional optimizations in src/fonts/runtime-fonts.ts:

  1. Three-stage scan before injecting: Raw HTML, live DOM innerText, and post-image layout text are inspected so pure English/Latin documents never pay base64 font CSS overhead.
  2. Scoped ONEX Rupee (U+20B9): Registers Noto Sans under alias 'ONEX Rupee' strictly on unicode-range U+20B9, placing Noto Latin only at the bottom tail of computed stacks. Existing Georgia, Arial, or corporate fonts stay intact while ₹ always renders crisply. Arabic content automatically receives dir="auto" and unicode-bidi: plaintext.

Converting 1990s Legacy Hindi Encodings

Old government databases frequently store Hindi inside legacy 8-bit font encodings (Kruti Dev 010 or Chanakya) where half-glyphs and short i matras (ि) were typed visually out of order.

  • krutiDevToUnicode() & chanakyaToUnicode() run greedy longest-match substitution (104 and 56 pairs) followed by PUA sentinel reordering (reorderDevanagariVisualMarks) across halant conjunct chains and NFC normalization.
  • normalizeLegacyIndicHtml() maintains an HTML tag font-family stack, converts only legacy font spans while sparing <script>/<style>, and switches font stacks over to Noto Sans Devanagari.
  • On render, convertLegacyFonts defaults to 'auto', making 20-year-old Kruti Dev templates immediately searchable in modern PDF readers without touching legacy source tables.

Clone this wiki locally