Persian ComputingwithUnicode
Behdad Esfahbod no visa
unicode@behdad.org

Amir Youssefi

youssefi@cs.rpi.edu

The FarsiWeb Project
http://www.farsiweb.info/March 31, 2004

What is Persian?

ContemporaryPersian

DariFarsi

Tajik

Afghanistan

IranTajikistan

2Persian in Computers

There are three relevant national standards:• ISIRI 3342:1992 Farsi 8-bit Coded Character Set for
Information Interchange (deprecated)• ISIRI 2901:1994 Keyboard Layout for Farsi: Characters inComputer• ISIRI 6219:2002 Information Technology -- Persian
Information Interchange and Display Mechanism, usingUnicode3

Modern Persian Script• Based on Arabic Script (U+0600..U+06FF block): With
some extra letters, some modified letters• But with completely different semantics and typographicalhabits• Is a bidirectional script: Is written from right to left, except
for numbers• Needs cursive joining: Two adjacent letters may be joined,
forming 1, 2, or 4 glyphs for each character: (for example
, , , )
4

Arabic Script Rendering

Input text

Logical order

After Bidirectional Algorithm

Visual order

After Arabic Joining Algorithm

Glyph list

After Ligation

Glyph listWhen RenderedOutput   With enough care, it is possible, to apply the above algorithms
in a different order, and get the same result.

5A Bidirectional Document (gedit/Pango)

5-aAlphabet• Extra letters:
U+067E Peh (), U+0686 Tcheh (),U+0698 Jeh (), U+06AF Gaf ()• Modified letters:
Character

Isol

FinaMediInit























U+0643 Arabic Letter Kaf(Arabic Kaf)

U+06A9 Arabic Letter Keheh(Persian Kaf)

U+064A Arabic Letter Yeh(Arabic Yeh)

U+06CC Arabic Letter Farsi Yeh

(Persian Yeh)
6

Alphabet (continued)• Three shapes of composed Hamza Above:
U+0623 Alef with Hamza Above (),U+0624 Waw with Hamza Above (),U+0626 Yeh with Hamza Above ()• Never used characters:
U+0649 Alef Maksura (): Like Yeh, but no dots at all
U+06C0 Heh with Yeh Above (): Should never be usedinstead of Heh, ZWNJ, Farsi Yeh or Heh, Hamza Abovesequence

7

Special Characters• U+0640 Arabic Tatweel, for a longer joining stem   →    • U+200C Zero Width Non-Joiner, to prevent joining → • U+200D Zero Width Joiner, to choose a joined glyph whenit would not join naturally

 . →  .
• U+200E Left-to-Right Mark, U+200F Right-to-Left Mark,and other bidirectional control chars (U+202A..U+202E)
8

Numbers• U+06F0..U+06F9 Extended Arabic-Indic Digits:٠ ١ ٢ ٣ 4 5 6 ٧ ٨ ٩instead of U+0660..U+0669 Arabic-Indic Digits:٠ ١ ٢ ٣ ٤ ٥ ٦ ٧ ٨ ٩• U+066C Arabic Thousands Separator and U+066B Arabic
Decimal Separator :٩’٨٧6’54٣.٢١٠
• Western numerals in Latin context. Persian numerals
everywhere else (page numbers, section numbers, . . . )9Other Characters• Harakat (Vowel) Non-spacing Marks: * + , - . / 0 1 . . .
• Arabic Punctuation Marks:
U+060C Arabic Comma (، ),U+061B Arabic Semicolon (‫) ؛‬,
U+061F Arabic Question Mark (4 ),U+066A Arabic Percent Sign (%),
• U+00AB, U+00BB Double Angle Quotation Marks ( ( ) )• Shared Punctuation Marks:
Latin full stop, exclamation mark, parenthesis, squarebrackets, . . .
10

10-a

Keyboard Layout
ISIRI 2901:1994, features:• All letters and punctuation marks• Reasonable placement• Persian digits• Regular and shifted keys only
• Some empty slots
11Iranian Standard Layout

11-aKeyboard Layout (continued)
Proposed update, features:• Fully backward-compatible with ISIRI 2901:1994• Unicode 4.0 repertoire, and complete support for ISIRI
6219:2002• Support quoting Arabic text
• Uses AltGr to add required but rarely used characters• Adds all ASCII punctuation marks, useful for editing XML,...
• Adds bidirectional control characters
12Proposed Iranian Layout

12-aFonts• Microsoft fonts are Arabic• Tahoma is the best looking one• Persian fonts are not Unicode compatible yet• The only ligature: Lam-Alef• Nastaliq is desired, but not possible yet

13The Nastaliq Style

13-aDate and Time• Three calendars in use!
Gregorian, to synchronize with the rest of the world
Jalali, the official calendar
Islamic, for some holidays and ceremonies• Islamic calendar depends on moon-sighting once a year
• Week starts Saturday• Business weekdays from Saturday to Thursday• 24-hour preferred in media• No AM/PM equivalent14Collation• Like Arabic basically•

6 <  < 5 < • Some L2 equal pairs:
 <34 <3 ٤→6 < 5 <  <  <3  7 <3 85 <3 ٥ 6 <3 ٦

• Traditional rules: Hamza variants are L2 equal: <3  <3 
• Modern rules: L2 equal with their base letter: <3  5 <3   <3 15

Loose SearchingZWNJ  SpaceZWNJ  empty string < ;:9   < =:9  

DCBA@ 7?>  DCBA@ ?>
 GFE  FEJ  JK
L  M?EH  ?EIHG ON  G@INPNIN  PNMN
5MN  LON
 N,   N+
 N+   N
 N   N,
٠  ٠ ... 4  ٤ 5  ٥ 6  ٦...٩  ٩16

Last Notes to Application Developers• Typesetting Persian paragraphs:
Justified lines
No inter-letter spacing
No word hyphenation
Almost no inter-word spacing
Use Tatweel instead: PN  → PN       • All text fields Right-to-Left• Persian numbers• Right-to-Left layout• Beware: Right and Left are swapped!
17

An Old-style Persian Poem (MS Word)

17-a

A Right-to-Left Dialog (Gtk+/Pango)

17-b

A Persian Paragraph (Mozilla)

17-c

A Persian Table (Mozilla)

17-dA Bidirectional HTML Dialog (Mozilla)
The HTML/CSS markup generating the two forms below isexactly the same, except for:
• The Persian form has lang=fa once for the body tag.
• The Persian form has direction: rtl once for the body tag.
• The English form, the labels all have align: right, in thePersian one they have align: left.
Unfortunately there is no way in CSS to drop the annoyingalign dierence.

17-eCurrent Status -- Microsoft Windows• Render correctly• Shipped fonts work
• Keyboard layout is terrible• No Persian digits support• No Iranian calendar• Locale data is wrong in places• No interface translation• Not trivial to enable Persian support
18

Current Status -- Linux• Important systems support rendering• No good fonts yet• Standard keyboard layout• No Persian digits support yet• KDE claims Iranian calendar support• Some interface translation done
• Not trivial to enable Persian support
19

Current Status -- MacOS• Supports rendering• No good fonts• Legacy and standard keyboard layouts

20

References and Resources• The Unicode Standard at http://www.unicode.org/• Institute of Standards and Industrial Research of Iran at
http://www.isiri.com (documents in Persian)• The FarsiWeb Project at http://www.farsiweb.info/• PersianComputing list at
http://lists.sharif.edu/mailman/listinfo/persiancomputing• Typing Persian Word Documents with Windows Tutorial at
http://students.washington.edu/irina/persianword/persianwp.htm
21