Typography Home Typography Home

Developing fonts > Specifications

Developing OpenType Fonts
for Arabic Script (2 of 3):
Shaping Engine

The Uniscribe Arabic shaping engine processes text in stages. The stages are:

  1. Analyzing the characters for contextual shape
  2. Shaping (substituting) glyphs with OTLS (OpenType Library Services)
  3. Positioning glyphs with OTLS

The descriptions which follow will help font developers understand the rationale for the Arabic feature encoding model, and help application developers better understand how layout clients can divide responsibilities with operating system functions.

Analyzing the Characters

The unit that the shaping engine receives for the purpose of shaping is a string of Unicode characters, in a sequence. The contextual analysis engine determines the correct contextual form the character should take, based on the character before and after it. The contextual shape maps to an OTL feature for that form (isol, init, medi, fina).

Additionally, during the analysis process, the engine verifies valid diacritic combinations. For additional information, see the Handling Invalid Combining Marks section.

Shaping with OTLS

The first step Uniscribe takes in shaping the character string is to map all characters to their nominal form glyphs (e.g. the glyph for U+0627). Then, Uniscribe applies contextual shape features to the glyph string.

Next, Uniscribe calls OTLS to apply the features. All OTL processing is divided into a set of predefined features (described and illustrated in the Features section of this document). Each feature is applied, one by one, to the appropriate glyphs in the syllable and OTLS processes them. Uniscribe makes as many calls to the OTL Services as there are features. This ensures that the features are executed in the desired order.

The steps of the shaping process are outlined below. Not all of the features listed apply to all Arabic script languages.

Shaping features:

  1. Language forms
    1. Apply feature 'ccmp' to preprocess any glyphs that require composition or decomposition (for example, 'alef' followed by 'hamza above' may be composed into 'alef with hamza above')
    2. Apply feature 'isol' to get the isolated form of characters
    3. Apply feature 'fina' to get final form glyphs
    4. Apply feature 'medi' to get medial form glyphs
    5. Apply feature 'init' to get initial form glyphs
    6. Apply feature 'rlig' to compose any mandatory ligatures, like 'lam alef'
    7. Apply feature 'calt' to apply any desired alternative forms of connections; this can provide type designers with the capability to contextually exchange a glyph to give a better calligraphic presentation
  2. Typographical forms
    1. Apply feature 'liga' to compose any optional ligatures, like 'lam meem'
    2. Apply feature 'dlig' to compose any discretionary ligatures
    3. Apply feature 'cswh' to substitute any swash characters based on context; for example, a swash 'noon' might be used if followed by n glyphs that do not extend below the baseline
    4. Apply feature 'mset' to apply mark positioning via substitution; this does not produce the best typographic possibilities as would the use of the positioning feature 'mark'

Top of page

Positioning Glyphs with OTLS

Uniscribe next applies features concerned with positioning, calling functions of OTLS to position glyphs.

Positioning features:

  1. Cursive connection
    1. Apply feature 'curs' to connect cursive font glyphs as appropriate
  2. Kerning
    1. Apply feature 'kern' to provide pair kerning between base glyphs requiring adjustment for better typographical quality
  3. Mark to base
    1. Apply feature 'mark' to position diacritic glyphs to the base glyph
  4. Mark to Mark
    1. Apply feature 'mkmk' to position diacritic glyphs to other diacritic glyphs

Handling Invalid Combining Marks

Combining marks and signs that appear in text not in conjunction with a valid consonant base are considered invalid. Uniscribe displays these marks using the fallback rendering mechanism defined in the Unicode Standard (section 5.12, 'Rendering Non-Spacing Marks' of the Unicode Standard 3.1), i.e. positioned on a dotted circle.

Please note that to render a sign standalone (in apparent isolation from any base) one should apply it on a space (see section 2.5 'Combining Marks' of Unicode Standard 3.1). Uniscribe requires a ZWJ to be placed between the space and a mark for them to combine into a standalone sign.

For the fallback mechanism to work properly, an Arabic OTL font should contain a glyph for the dotted circle (U+25CC). In case this glyph is missing form the font, the invalid signs will be displayed on the missing glyph shape (white box).

In addition to the 'dotted circle,' other Unicode code points that are recommended for inclusion in any Arabic font are: ZWJ (zero width joiner U+200C), ZWNJ (zero width non-joiner; U+200D), LTR (left to right mark; U+200E), and RTL (right to left mark; U+200F). The ZWNJ can be used between two letters to prevent them from forming a cursive connection.

If an invalid combination is found, like two fathas on the same base character, the diacritic that causes the invalid state is placed on a dotted circle to indicate to the user the invalid combination. The shaping engine for non-OpenType fonts will cause invalid mark combinations to overstrike. This is the problem that inserting the dotted circle for the invalid base solves. It should also be noted that the dotted circle is not inserted into the application's backing store. This is a run-time insertion into the glyph array that is returned from the ScriptShape function.

The invalid diacritic logic for Arabic is based on the classes listed below. There is a check to make sure more than one mark of a class is not placed on the same base. Additionally, DIAC1 and DIAC2 classes should not be applied on the same base character.

ClassDescriptionCode points
DIAC1Arabic above diacriticsU+064B, U+064C, U+064E, U+064F, U+0652, U+0657, U+0658, U+06E1
DIAC2Arabic below diacriticsU+064D, U+0650, U+0656
DIAC3Arabic seat shaddaU+0651
DIAC4Arabic Qur'anic marks aboveU+0610 - U+0614, U+0659, U+06D6 - U+06DC, U+06DF, U+06E0, U+06E2, U+06E4, U+06E7, U+06E8, U+06EB, U+06EC
DIAC5Arabic Qur'anic marks belowU+06E3, U+06EA, U+06ED
DIAC6Arabic superscript alefU+0670
DIAC7Arabic maddaU+0653
DIAC8Arabic maddaU+0654, U+0655

Next section:  Features

introduction | shaping engine | features | appendices


Top of page