1 Star2 Stars3 Stars4 Stars5 Stars (2 votes, average: 5.00 out of 5)

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




Social Comments

9 Advanced Comments

Ahmed Ibrahim
May 29th, 2010

Good job man :)



May 29th, 2010

Thank you ..

vivek
June 21st, 2010

Thanks a lot for the library.This has made our life much easier. I want to use this but the problem that i am facing is total size of my application. I am using multiple flash swf that is loaded on-demand.Currently i have embedded font in all the movies and able to deliver arabic content.

But I want to embed that font in the base movie and want others to share (with linkage) the embeded font.

Do you see any issue with this?

If possible, Can you please give a sample on the same?

Vivek
June 24th, 2010

I am facing problem running this with linked font library and text box is showing me blank text.



July 8th, 2010

Here is a step-by-step tutorial for using shared fonts in ActionScript 2.0 with the use of Arabic Parsing solution ..

For ActionScript 3.0 follow this tutorial ..

Edwin
October 11th, 2010

I can’t seem to change the fontsize of the text – am I missing something? I’ve tried with textformat as shown in the example, but I really want to use a stylesheet. No matter what I try, the text comes out the same small size. Here’s part of my code:

var arabTxt:String = utils.parseArabic(myString);

pageTitleTF = bg_pageTitle_mc.createTextField(“pageTitleTF”, bg_pageTitle_mc.getNextHighestDepth(), 0, 0, 1, 1);
pageTitleTF.autoSize = “right”;
pageTitleTF.embedFonts = true;
pageTitleTF.styleSheet = appObj.getDisplayStyleSheet();

pageTitleTF.text = “” + arabTxt + “”;

Edwin
October 11th, 2010

sorry – the tags didn’t show up – that last line should have the proper tags around it

p class=’pagetitle’

and

/p

Edwin
October 11th, 2010

Okay got it working with textFormat but would still like to use a styleSheet. thanks!



January 5th, 2011

@Edwin

It works, here is an example:

import TextField.StyleSheet;
import com.xvisage.utils.StringUtils;
var utils:StringUtils = new StringUtils();
var style:StyleSheet = new StyleSheet();
style.load("arabic.css");
style.onLoad = function(done:Boolean) {
	if (done) {
		var styleObj:Object = style.getStyle(".arabic");
		var tf:TextFormat = style.transform(styleObj);
		output.htmlText = utils.parseArabic(myString, output, tf);
	}
};

Where “arabic.css” contains:

.arabic {
	font-family:Traditional Arabic; /*do not use single or double quotes around the font-family value ..*/
	font-size:20px;
}

And you need to use the most recent version available here