The display module provides support for internal text shaping. Text shaping is used on arabic text - which has a cursive nature - in order to make characters look connected. This is achieved by replacing characters in the arabic unicode block with their initial, medial, isolated and final forms in the arabic presentation block. The text shaper also applies ligatures to combinations of arabic characters where a compound character exists that represents the combination.
Apart from arabic text, Opera's internal text shaper is used to swap the devanagari (dependent) vowel sign i and the syllable it changes. This has nothing to do with text shaping per se, and is done for practical reasons only, the reason being that the devanagari (dependent) vowel sign i is the only (dependent) vowel sign (in the devanagari range) that is drawn to the left of the syllable it changes.
The text shaper is active whenever the feature FEATURE_INTERNAL_TEXTSHAPER is set, and the API API_DISPLAY_TEXTSHAPER is imported.
Prior to being moved to display, the text shaper resided in docutil. There has also been some changes in how the text shaper works in relation to the text shaper in docutil. Key points are:
The only function in the text shaper that can run out of memory is Prepare, in which case it will return the corresponding OP_STATUS. Thus, reporting OOM is left to the caller.
The TextShaper class uses some const arrays on the stack to store various attributes of arabic characters, as well as some other information. The current stack arrays exist:
The text shaper stores a TempBuffer in the DisplayModule object. This TempBuffer is set to hold the length of the input string whenever Prepare is called. Thus, the size of the TempBuffer depends on the input data. The minimum size of the TempBuffer is 30 uni_chars. Since the DisplayModule object holds the TempBuffer, it is also responsible for cleanup.