Skip to main content

Open-Source Arabic Parsing v1.5

Update: a newer version available here

Now you can integrate my parser into your library as open-source under GNU GPL license ..

ActionSctipt 2.0 version available here
ActionSctipt 3.0 version available here

Features Supported:

  1. Embedding Fonts (just put a dynamic textfield on-stage and select at least Basic Latin (95 glyphs) and Arabic (1088 glyphs) from the Character Embedding menu).
  2. Arabic Ligatures.
  3. Word Wrapping.
  4. Bi-Directional text.
  5. HTML Text.
  6. Loading External text on run-time.
  7. Windows/Mac/Linux support.
  8. Arabic enabled input fields using actionscript method (createArabicInput) with the help of javascript (arabicinput.js) beta

Features Not Supported:

  1. Arabic Diacritics (not necessarily for reading Arabic language in general, arabs are using diacritics mostly for writing Quran, and in that case diacritics are not the only missing feature, there’re many other ligatures cases in Arabic used for Quran writing).

You can use the old example found here, just replace the StringUtils.as class file ..

Multitasking Illusion

What is multitasking? it is the practice or capability of handling more than one task at the same time ..

It is said that our brain is capable of performing certain dual multiple tasks at the same time, for example, listening to the radio while writing an email, increasing the amount of tasks was one of the very basic reasons for inventing the CPU from the first place ..

Well, I completely disagree, actually there is no such thing as multitasking, only context switching which simulates multitasking, even for the CPU!
Let me explain ..

Human brain and CPU are quite different, our brain is more complicated, so I will take the CPU for an easier example ..
Consider that you need to perform 2 tasks on your PC, each requires exactly 10 seconds ..
The total time required will be 20 seconds for both tasks if running sequentially, first task will be completed after 10 sec and second task after 20 sec ..
But if you run both tasks simultaneously with the use of what called CPU multitasking, the CPU will do a context switch between both tasks, in other words, breaking down each task to segments and switch back and forth between them, assuming that each task will have 10 segments, each segment requires one second, then first task will be processed at odd seconds (1, 3, 5, ..) and second task at even seconds (2, 4, 6, ..), in that case we will have first task completed after 19 sec and second task after 20 sec, considering that the switch takes no time at all !!

Imagine the above procedure in our brain with the unexpected time required for the context switching, there is no accurate numbers but obviously the sequential approach will take much less processing than the simultaneous one, using only one switch between tasks !

On the other hand, human context switching (what I call distraction) means spreading attention among tasks, like talking on the phone while driving a car, since 2003 car accidents increased about 40% because of cell phones!

Observation:

  • CPU can not actually perform simultaneous tasks, it uses context switching to simulate multitasking, even with mutli-core processors, yet each core still performs exactly the same.
  • Context switching will not reduce the total time required for all tasks, it just adds an extra time for the switching operation.
  • Multitasking more accurately refers to Managed Tasking!
  • Human context switching consumes much more time than the CPU, in addition to the continuous partial attention.

Conclusion:

Never think or act simultaneously!

Facts:

Arabic Parsing and Shared Fonts

This tutorial uses ActionScript 2.0, for ActionScript 3.0 follow this one ..

The following is a step-by-step tutorial for using shared fonts in Flash with the use of Arabic Parsing solution:

  1. Create New Flash file to store shared fonts, in this case “arabic_fonts.fla”
  2. Create new MovieClip symbol, in this case “arabic_fonts” and check the option “Export for runtime sharing”, in this case “arabic_fonts.swf”
  3. Edit “arabic_fonts” MovieClip and create as many TextFields as you require, each with specific font to be shared
  4. Select each TextField individually and embed fonts from the properties panel
  5. Make sure you have checked the Arabic glyphs and you have chosen font name for linkage
  6. Complie the output movie, save and close “arabic_fonts.fla”
  7. Open your rendering Flash file, in this case “arabic_as2.fla” located in the same directory with “arabic_fonts.fla”
  8. Create new MovieClip symbol and give it the exact same name for the shared library symbol, in this case “arabic_fonts”, then check the option “Import for runtime sharing”, in this case “arabic_fonts.swf”

    When asked to edit the newly created symbol, make sure that you choose “No”

  9. Drag and instance of “arabic_fonts” MovieClip off-stage
  10. Compile the output movie, you should see fonts displayed correctly
  11. Download sample files here

Golden Egypt Web Award

It’s my pleasure to announce that the official website for Rola Mahmoud has won a Gold Award at Egypt Web Academy 2010 in Personal Category ..
No silver award has been rewarded in that category, only 2 other bronze, kind of an exclusive achievement .. Rola’s high intuitions was the key which led to such a successful project, she provides the perfect brief you can ever have, thank you Rola, thank you very much and congratulations ..

Rola Mahmoud & Ahmed Abbas

Another recent project also has won an award, an educational project called Nile Egyptian Schools, rewarded a Bronze Award in Governmental Organizations Category ..

ActionScript 2.0 Arabic Parsing v1.4

Update: a newer version available here

Well, I discovered some annoying bugs, all fixed in this version ..
As per my previous post here, I still recommend embedding fonts to avoid improper rendering.

ActionSctipt 2.0 version available here
ActionSctipt 3.0 version available here

Requirements:

  1. Dynamic TextField
  2. HTML Enabled TextField
  3. Pre-Assigned TextFormat
  4. Arabic Font

Recommended Properties:

  1. embedFonts: for proper rendering on Mac/Linux.

Properties:

  1. data: for referencing original input string, use the data property (utils.data) instead of (TextField.text) where “utils” is an instance of StringUtils class.
  2. wrapFactor: optional reduction value (Mac only) for wrapping correction when using bi-directional text, possible values: .98 or less.
  3. htmlLines: array of spliced text block HTML lines.
  4. numLines: integer value of total text block lines.

Features Supported:

  1. Embedding Fonts (just put a dynamic textfield on-stage and select at least Basic Latin (95 glyphs) and Arabic (1088 glyphs) from the Character Embedding menu).
  2. Arabic Ligatures.
  3. Word Wrapping.
  4. Bi-Directional text.
  5. HTML Text.
  6. Loading External text on run-time.
  7. Windows/Mac/Linux support.
  8. Arabic enabled input fields using actionscript method (createArabicInput) with the help of javascript (arabicinput.js) beta

Features Not Supported:

  1. Arabic Diacritics (not necessarily for reading Arabic language in general, arabs are using diacritics mostly for writing Quran, and in that case diacritics are not the only missing feature, there’re many other ligatures cases in Arabic used for Quran writing).

Change List:

  1. Proper rendering for HTML bullet list (include the bullet character “•” in the Character Embedding menu).
  2. Optimized conditions for basic thorough loop.
  3. New properties for referencing text block lines (htmlLines, numLines).

Fixed Bugs:

  1. Multi-level HTML tags, for example:
      <a href="#"><font>text</font></a>
  2. Line-break determination on Mac.

Known Bugs:

  1. Improper wrapping for non-embedded fonts only on Mac when begin text line with non-Arabic characters or when using custom format HTML tags.

Here is an example works with this external XML file (with run-time resizing vs. wrapping):


download the above example here

Test files are available here using ASUnit Framework