Arabic text with Haxe 3, flash

309 views
Skip to first unread message

Tom

unread,
May 3, 2013, 6:25:00 AM5/3/13
to haxe...@googlegroups.com
Hi!

Any good solution to display dynamic Arabic text in Haxe flash? I need to do it today, so I have no much time, please help me out.
The Adobe flash TFL engine is not embeddable, or I can't figure out, how to do it.

Any idea is welcome!

Tom

clemos

unread,
May 3, 2013, 6:33:07 AM5/3/13
to haxe...@googlegroups.com
I believe Flaraby works well : http://www.arabicode.com/
Otherwise, depending on what you want to achieve, using embedFonts=false might do the trick.

Regards,
Clément




Tom

--
To post to this group haxe...@googlegroups.com
http://groups.google.com/group/haxelang?hl=en
---
You received this message because you are subscribed to the Google Groups "Haxe" group.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Cristian Baluta

unread,
May 3, 2013, 6:40:26 AM5/3/13
to haxe...@googlegroups.com
I've done it some time ago and don't recall to have major problems, i think i've used system fonts.
--
Băluță Cristian
http://ralcr.com
http://imagin.ro

Tom

unread,
May 3, 2013, 6:55:06 AM5/3/13
to haxe...@googlegroups.com
If I export an swc from Adobe flash which one includes TLF, then I try to add to library in Flashdevelop. But just say: Class not found : fl.text.TLFTextField
If I unpack the swc, and just use the swf from it, then during the compile, the swf from the "obj" folder is missing.

How do you do it before?

Mike Welsh

unread,
May 3, 2013, 1:20:19 PM5/3/13
to haxe...@googlegroups.com
One thing you need to be careful of is that TLF is by default set to link as a Run-time share library, so it is not linked into the SWF but instead loaded externally. If you go to File->Publish Settings->ActionScript Settings, you an change the linkage type to Merged into code to ensure that it gets outputted into the resulting SWF/SWC.

Not sure if this helps your particular problem, but something to look into!

Tom

unread,
May 3, 2013, 3:24:42 PM5/3/13
to haxe...@googlegroups.com
Thanks for the tip. I tried this, but not success. :(
The SWC was not usable with Haxe 3 RC1 from flashdevelop - did not see the classes in it.
And the SWF was not compilable... maybe some hacking can help with it, I don't know.

j...@justinfront.net

unread,
May 3, 2013, 5:25:04 PM5/3/13
to haxe...@googlegroups.com
Tom

> One thing you need to be careful of is that TLF is by default set to
> link as a Run-time share library, so it is not linked into the SWF
> but instead loaded externally. If you go to File->Publish Settings-
> >ActionScript Settings, you an change the linkage type to Merged
> into code to ensure that it gets outputted into the resulting SWF/SWC.

Yep you need to do that for it to be in the swf. Rather than use it
at compile time, maybe easier to just load it at runtime into the same
application domain, and grab a MovieClip with a TLF textfield in and
just put it on your stage, I would probably put the textfield in a
Sprite create an instance and then grab the textfield from the
instance. But I have not used TLF much, I don't know I prefer normal
textfields but then again I have not done any arabic.

If you get really stuck look into Jan hxswfml you can process the
characters to classes of draw commands ( his tools do that already
really well ) and then it's just up to you to lay them out yourself.
I would not advise parsing all without some mods to the code best to
select the letters you need. But anyway here is an example of how you
can even parse font on the fly using hxswfml.

package;
import format.ttf.Data;
import be.haxer.hxswfml.FontWriter;
class Main
{ static function main()
{ var loada = new flash.net.URLLoader(new
flash.net.URLRequest('Arial.ttf'));
loada.dataFormat = flash.net.URLLoaderDataFormat.BINARY;
loada.addEventListener( flash.events.Event.COMPLETE,
function(e){
var fontWriter = new be.haxer.hxswfml.FontWriter();
fontWriter.write( haxe.io.Bytes.ofData( e.target.data ),
'all', 'hash' );
var letterHash = fontWriter.getHash();
var a = letterHash.get(65);
var sp = new flash.display.Sprite();
sp.scaleX = 0.1;
sp.scaleY = 0.1;
sp.x = 100;
sp.y = 100;
flash.Lib.current.addChild( sp );
var g = sp.graphics;
g.lineStyle(0,0,1);
g.beginFill(0,1);
g.lineTo( 50,50 );
g.drawPath( a.commands, a.data,
flash.display.GraphicsPathWinding.EVEN_ODD );
g.endFill();
});
}
}

Thursday we just shipped a new version of videoscribe ( which uses as3
code ) but we are using haxe just for font, it uses a modified hxswfml
for on the fly parsing of font to svg, there is a wait when a user
wants a new font but if you use Jan's classes to create haxe glyphs
then you would not have this lag.

Sorry can't help more been so long since I looked at TLF and decided I
did not like it much.

Good luck

Justin

Tom

unread,
May 4, 2013, 1:49:56 AM5/4/13
to haxe...@googlegroups.com
Thanks for Your effort! I will try this. And beside it, maybe I will write a class, which can "reshape" any Arabic text into well formatted and connected character codes.

simo

unread,
Nov 28, 2013, 8:13:47 AM11/28/13
to haxe...@googlegroups.com
Hello Tom,

I like to know about your case please, did you manage to view arabic text, with letters connected correctly?

Tom

unread,
Nov 28, 2013, 5:39:41 PM11/28/13
to haxe...@googlegroups.com
Hi Simo!

I have two methods:
1. I have made an SWC with embedding the needed TextLayout Framework, with TLFTextField. Because Haxe can't include any font embed as CFF, the anti-aliasing is bad, and ugly.
2. So I write a class, which can reformat an Arabic string with the correct character code, to connect them. (Sorry for that, but I can't let this code to public, because my company doesn't allow it. There are some partially working/buggy implementation out there, just need to fix them...)

If You need a good looking, anti-aliased input field, then You must use CFF embedded font, from Adobe Flash, or do some trick.

Best regards!
Tom

Samir Sabri

unread,
Dec 1, 2013, 9:18:55 AM12/1/13
to haxe...@googlegroups.com
Thanks for the valuable info, so if I you embed needed TextLayout in swc file, you can use it in your openFL project?!
As for the class that reformat Arabic string with the correct character, it would be a great open source project if your company allows .. that's sad ..
But I think, the key to reformat arabic characters is to use unit code of each letter in all possible shapes, right?

Thanks for sharing your experience,
Samir


You received this message because you are subscribed to a topic in the Google Groups "Haxe" group.

For more options, visit https://groups.google.com/groups/opt_out.



--
--
Kind Regards,
--------------------------------------------- 
Samir Sabri
Software Architect& Developer
Jordan-Middle East

Justin L Mills

unread,
Dec 1, 2013, 11:46:16 AM12/1/13
to haxe...@googlegroups.com
I don't think you can use swc's in OpenFL if the target is not
flashplayer ( well coded swf's loaded into openfl will loose the as3
code ) but you could try decompiling the ABC using hxformat on the
TextLayout.swc I believe it's as as3 implementation. But not sure if
the textLayout as3 code would work in OpenFL or be setup only for
flashplayer, and to me atleast it does not seem legitimate to
deconstruct the TextLayout without Adobe consent. Theoretically similar
to what I suggested you could create kerning data using hxswfml and the
font and then just use a textfield for each letter and code the layout
to type left to right.

So basically you would do a lookup for every pair of letters from a
pre-created fontKerning hash of some sort.

var dSpace = kern.get( 'a_b' );

I am not sure if OpenFL when creating the bitmaps used for font in c++
language processes kern, but you can probably modify the code of how it
lays out letters. I would think if you dug deep everything is there for
OpenFL c++ target to be amended to allow writing left to right, it's
just likely to be some effort.


Samir Sabri:
> Thanks for the valuable info, so if I you embed needed TextLayout in swc
> file, you can use it in your openFL project?!
> As for the class that reformat Arabic string with the correct character, it
> would be a great open source project if your company allows .. that's sad ..
> But I think, the key to reformat arabic characters is to use unit code of
> each letter in all possible shapes, right?
>
> Thanks for sharing your experience,
> Samir
>
>
> On Fri, Nov 29, 2013 at 1:39 AM, Tom <hortoba...@gmail.com> wrote:
>
>> Hi Simo!
>>
>> I have two methods:
>> 1. I have made an SWC with embedding the needed TextLayout Framework, with
>> TLFTextField. Because Haxe can't include any font embed as CFF, the
>> anti-aliasing is bad, and ugly.
>> 2. So I write a class, which can reformat an Arabic string with the
>> correct character code, to connect them. (Sorry for that, but I can't let
>> this code to public, because my company doesn't allow it. There are some
>> partially working/buggy implementation out there, just need to fix them...)
>>
>> If You need a good looking, anti-aliased input field, then You must use
>> CFF embedded font, from Adobe Flash, or do some trick.
>>
>> Best regards!
>> Tom
>>
>> 2013. november 28., cs�t�rt�k 14:13:47 UTC+1 id�pontban simo a k�vetkez�t
>> �rta:
>>
>>> Hello Tom,
>>>
>>> I like to know about your case please, did you manage to view arabic
>>> text, with letters connected correctly?
>>>
>>> On Saturday, May 4, 2013 8:49:56 AM UTC+3, Tom wrote:
>>>>
>>>> Thanks for Your effort! I will try this. And beside it, maybe I will
>>>> write a class, which can "reshape" any Arabic text into well formatted and
>>>> connected character codes.
>>>>
>>>> 2013. m�jus 3., p�ntek 23:25:04 UTC+2 id�pontban JLM a k�vetkez�t �rta:

Tom

unread,
Dec 2, 2013, 12:15:19 AM12/2/13
to haxe...@googlegroups.com
The SWC file can be used only in flash target
And You are right, the key is to identify the Arabic characters, and fine the correct unicode glyph (alone, first, last, inner).
The correct kerning is another problem eg. in C. Maybe we need a correct font renderer. :)

Samir Sabri

unread,
Dec 2, 2013, 1:02:01 AM12/2/13
to haxe...@googlegroups.com

Thanks for insights .. if I managed my time to do it, I will surely make open source project at github ..

>> 2013. november 28., csütörtök 14:13:47 UTC+1 időpontban simo a következőt
>> írta:
>>
Reply all
Reply to author
Forward
0 new messages