Download the PHP package imsoft-dev/devanagari-reshaper without Composer
On this page you can find all versions of the php package imsoft-dev/devanagari-reshaper. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download imsoft-dev/devanagari-reshaper
More information about imsoft-dev/devanagari-reshaper
Files in imsoft-dev/devanagari-reshaper
Package devanagari-reshaper
Short Description PHP library for correcting Devanagari i-matra (ि) visual rendering order for legacy renderers (PDF, canvas, etc.)
License MIT
Informations about the package devanagari-reshaper
devanagari/reshaper
A lightweight PHP library for correcting Devanagari i-matra (ि) rendering order in systems that do not perform Unicode shaping — such as legacy PDF generators, canvas renderers, or custom font engines.
The Problem
In Unicode logical order, the short-i matra (U+093F) is stored after its consonant:
Modern browsers and OS text stacks reorder this visually. But legacy renderers (FPDF, TCPDF, canvas, some PDF libs) render characters left-to-right in byte order, producing:
This library physically swaps the bytes so legacy renderers display the correct result.
Features
- ✅ Simple consonants:
क + ि → ि + क - ✅ Combining nukta forms:
ड + ़ + ि → ि + ड + ़ - ✅ Pre-composed nukta forms:
ज़ (U+095B) + ि → ि + ज़ - ✅ Deep conjunct clusters:
स्त्र + ि → ि + स्त्र(unlimited depth) - ✅ HTML-safe: only text nodes are processed, attributes are untouched
- ✅ Invisible marker stripping (BOM, ZWNJ, ZWJ)
- ✅ Batch array reshaping
- ✅ Cheap pre-check via
needsReshaping()
Requirements
- PHP 8.0+
ext-mbstring
Installation
Usage
Plain text
HTML (tag-safe)
Array of strings
Guard check (performance)
How it works
A consonant cluster is defined as:
Where a consonant_unit is:
The regex finds every cluster + i-matra sequence and moves the i-matra to the front:
Running tests
License
MIT
All versions of devanagari-reshaper with dependencies
ext-mbstring Version *