as3 中的阿拉伯语文本

发布于 2024-10-11 11:19:45 字数 26 浏览 6 评论 0原文

如何使用as3从右到左显示阿拉伯文本?

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

深巷少女 2024-10-18 11:19:45

这段代码可以解决这个问题:

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);

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);
江挽川 2024-10-18 11:19:45

文本布局框架可以处理从右到左的文本。

The Text Layout Framework can handle right to left text.

下壹個目標 2024-10-18 11:19:45

我知道这是一个旧线程。但仍然是 RTL 文本最有用的片段。谢谢艾伦。

让我添加一些在 CC 时代在 Flash Builder 4.7 上为 iOS 编码的经验:

Flash Builder 不附带在 iOS 上显示阿拉伯语和其他 RTL 语言所需的 TLFTextField 及其支持类。

在 CS6 和 CC 之间,Adobe 甚至从 Flash Professional 中删除了这些课程。可能是因为标准 TextField 类已得到改进。

尽管如此,在 iOS 上,RTL 和阿拉伯语连字仍无法开箱即用。如果使用FlashBuilder的TextField类AirSimulator会正确显示。如果你在 iOS 上运行相同的代码则不然。

StageText 及其 NativeText 包装器将正确呈现,但对于静态文本确实有缺点。

您可能会考虑重新引入 TLFTextField。具体操作方法如下:

  • 从 Creative Cloud 安装 Flash Professional CS6 (!)
  • 在程序文件夹的“libs”子文件夹中,您将找到两个 SWC,其中包含使用 TLFTextField 所需的类:TLFRuntime.swc 和 TLFRuntime.swc。 textLayout.swc
  • 将 SWC 复制到 ProjectFolder 中,并通过打开项目的属性 -> 将其包含在 Flash Builder 中ActionScript 构建路径 ->库路径->添加 SWC(或添加 SWC-Folder)

这应该使 Ellen 的代码可以在带有 Air SDK 3.9 的 iOS 版 FlashBuilder 4.7 上运行

。您可能会期望标准 TextField 在未来版本的 Air 中正确显示阿拉伯语和其他 RTL 语言。

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.

从此见与不见 2024-10-18 11:19:45

此外,您可能需要包含在库中使用的字体

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

清秋悲枫 2024-10-18 11:19:45

尝试添加适当右对齐的文本格式

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

try to add textformat with propriety right alignment

var txtFormat:TextFormat = new TextFormat();
txtFormat.align = "right";
蹲在坟头点根烟 2024-10-18 11:19:45

我也在 FlarabySWF 上取得了成功 - 它花费了一些钱(不是很多),但它确实有效根据我的经验,效果很好。

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

浅沫记忆 2024-10-18 11:19:45

如果您不反对 Flex 框架,它现在包含一个不错的国际化库,应该可以让您轻松地做到这一点。这是一个不错的起点 http://devgirl.org/2011/03 /15/flex-4-本地化/

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/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文