syllable / shaping
Syllable Font Shaping Library for Arabic/Persian Texts
Requires
- php: ^7.4
- ext-mbstring: *
This package is not auto-updated.
Last update: 2024-05-18 02:49:57 UTC
README
Syllable Font Shaping Library is an implementation of font shaping algorithm for Arabic/Persian texts. It replaces Unicode code-points in a text with their presentation forms in correct order, to leverage font rendering libraries, such as FreeType—and also PHP extensions which use FreeType, e.g. GD—to render Arabic/Persian texts correctly.
Pleas keep in mind that this library does not change the words order, since it may depend on the placements of the line-breaks, which this library does not understand. So, you would need to handle the words order later.
Note. This is still a work in progress and due for breaking changes, and may or may not be ready to be used in production.
Quick Start
This is a simple example for using the Shaper
class:
use Syllable\Shaping\Shaper;
$shaper = new Shaper();
$shapedText = $shaper->shape('نموذج', Shaper::RTL);
The second parameter of the shape
method is optional and specifies the
direction of the flow of the text. It helps the shaping algorithm to place
punctuations and enclosing marks in the correct shape and order if the given
text is within a larger context. If you do not determine the direction, it
will make a guess based on the given text.
License
Syllable Font Shaping Library is made public under the MIT license.