Arabic text in as3

感情迁移 提交于 2019-12-04 11:39:29

问题


How can I display arabic text from right to left with as3?


回答1:


This code will do the trick:

import flash.text.AntiAliasType;
import flash.text.TextField;
import flash.text.TextFieldAutoSize;
import flash.external.*
import fl.text.TLFTextField;
import flash.text.TextFormat;

import flashx.textLayout.formats.TextLayoutFormat;
import flashx.textLayout.elements.TextFlow;


var arabicTextField:TLFTextField = new TLFTextField();
arabicTextField.antiAliasType = AntiAliasType.ADVANCED;
arabicTextField.mouseEnabled = false;
arabicTextField.selectable = false;

arabicTextField.direction = flashx.textLayout.formats.Direction.RTL;

var fmt:TextFormat = new TextFormat();
fmt.color = 0xFFFFFF;
fmt.font = "arialArabic"
arabicTextField.embedFonts = false;
arabicTextField.defaultTextFormat = fmt;
arabicTextField.setTextFormat(fmt);



回答2:


The Text Layout Framework can handle right to left text.




回答3:


I know this is an old thread. But still the most useful snippet around for RTL Text. Thanks Ellen.

Let me add some experiences in coding for iOS on Flash Builder 4.7 in times of CC:

Flash Builder doesn't ship with the TLFTextField and its supporting classes needed to display Arabic and other RTL languages on iOS.

Between CS6 and CC Adobe has even dropped those classes from Flash Professional. Probably because the standard TextField class has been improved.

Still, on iOS RTL and and Arabic Ligatures will not work out of the Box. If you use the TextField class AirSimulator of FlashBuilder will display correctly. Not if you run the same code on iOS.

StageText and its NativeText wrapper will render correctly but do have disadvantages for static text.

You might think of reintroducing TLFTextField. Here's how you can do it:

  • Install Flash Professional CS6 (!) from the Creative Cloud
  • In the "libs" subfolder of the programfolder you'll find two SWCs that contain the classes needed to use TLFTextField: TLFRuntime.swc & textLayout.swc
  • Copy the SWC in your ProjectFolder and include it in Flash Builder by opening your project's properties -> ActionScript Build Path -> Library Path -> Add SWC (or Add SWC-Folder)

This should make Ellen's code work on FlashBuilder 4.7 for iOS with Air SDK 3.9

You could probably expect the standard TextField display Arabic and other RTL languages correctly in future releases of Air.




回答4:


Additionally, you probably will need to include the fonts you use in your library




回答5:


try to add textformat with propriety right alignment

var txtFormat:TextFormat = new TextFormat();
txtFormat.align = "right";



回答6:


I've also had success with FlarabySWF - it costs some money (not alot) but it actually works quite well in my experience.




回答7:


If you're not opposed to the flex framework, it now includes a decent internationalization library that should allow you to do this easily. Here's a decent place to get started http://devgirl.org/2011/03/15/flex-4-localization/



来源:https://stackoverflow.com/questions/4652021/arabic-text-in-as3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!