Hello there,
I have started fiddling with gideros and arabic again.
Let me explain: I have an arabic word with vowels! I transform it to numbers depending on the letter, then I transform the vowel to a string. Then I map those to a .png and show it to the screen.
That's it. I need to work on position and more stuff, but that should do it for my needs.
PS: the older answers do not work in some cases, so I had to do it from scratch.
PS2: i won't be here for the next two weeks!
Have fun people.
Peace.
Comments
The code is a bit long because it accepts 15 letters and I like when the code is not in one block.
You can put spaces to make a sentence.
The way I call it (anywhere in my project):
The class:
https://github.com/mokalux/gideros/tree/master/arabic
Bye.
I'm also interested in how to work with arabic symbols, thx for your information!
I usually just use arabic ttfonts from the internet:
"What one programmer can do in one month, two programmers can do in two months." - Fred Brooks
“The more you do coding stuff, the better you get at it.” - Aristotle (322 BC)
Yes, I have tried that too with other fonts but some letters weren't attached properly. I believe there is some code left in the repo that shows that. Plus I added vowels! will work more on this when coming back then I'll post the whole thing insha'Allah.
I'd like to integrate it into gideros, so I'd be glad if some arabic speaker/writer could check it up!
Likes: SinisterSoft
https://deluxepixel.com
I understand a little bit more of lua but i don't think i can fix your code but I am willing to share everything I've got because I am in love with gideros and you guys
I am working with unicode for arabic:
ex: 1574 ئ
this allow us to deal with vowels as well.
Some quotes from an excel forum:
Function atu(rng As Range) As String
' arab word to unicode
Dim i As Integer
Dim CellValue As String
Dim arabunicode As Integer
Dim NewValue As String
'Get the string from the cell. Although it may not look like it
'this is in fact unicode. It's kinda hidden from you.
CellValue = rng.Value
'go through the string character by character (note that
'each character is 2 bytes - you just don't see it)
For i = 1 To Len(CellValue)
'get the unicode value for this character
arabunicode = AscW(Mid$(CellValue, i, 1))
'append this to our string - as unicode
NewValue = NewValue & arabunicode
Next i
'Write our string back to the cell.
atu = NewValue
End Function
See attached my excel experiment.
The only problem is that it has a limited number of characters (15 in my gideros function), but it can handle vowels, spaces, comma, column, ...
The function is not complete yet because I wanted to give it a try before leaving.
When i am back i should complete it and share the whole class again with a use case. But the basics are here in the github (some classes are missing I believe because they were linked classes, but they are like the basics class for buttons, easing,...)
So the way I do it is via a texture pack of all the letters isolated, beginning, middle and end of words. Then I add some more graphics for the vowels and voilà.
Hope that will help you guys. You give us so much you need some payback.
In the meantime I am going to have a look at your code again to see what I understand from it (but it's hard because you put too few comments ).
Could you just tell me what are those 0x... symbols?
Peace.
Plus for the vowels we need to have a code for them as well. For example letter N + vowel A = 16061614 in unicode.
نَ 16061614
where ن = 1606
and 1614 = َ
I will at your example to see if I can understand what goes wrong in my code
However it turns out that a lot of fonts are buggy: they report a non zero advance distance for those characters. I was using arial.ttf it IS buggy. I switched to NotoSansArabic and it already looks better, although the diacritic mark doesn't seem to be correctly cenetered...
I used the following test:
Likes: MoKaLux
I am looking at to which extent hafbuzz could be made a plugin, hooking into gideros text rendering. The good thing is that it is MIT licensed
Likes: Apollo14, MoKaLux
https://github.com/godotengine/godot/pull/21791
The conversation is interesting because they speak of licences too. The code is C++.
I keep on looking!
It supports vowels and does not limit your text to 15 characters =(
The only issue here is that users will have to translate their text to unicode and then use your code.
Or am i missing the point and you try to implement harfbuzz to do this for us?
I had a look at ICU and it seems to do the same thing as harbuzz?
http://userguide.icu-project.org/intro
Personally, your code should be all I need for all of my project where I pass in the unicode to show some arabic text.
Thank you a ton @hgy29
In order to display a text, we have to go through several steps. Roughly:
1. Get a string with the text we want to display: lua strings are only 8 bit, so in gideros texts are expected to be UTF8 encoded. This is what the editor do automatically, but this cause trouble with RTL texts such as arabic, so I used utf8.char() to encode the two codepoints 1606 and 1614 into UTF8 by code for better readability.
2. text is separated into RTL and LTR chunks. This is a process known as BiDi algorithm. As part of this process RTL texts are reversed to displayed LTR by drawing engine. Gideros doesn't do that step at all and just assume texts are always LTR.
3. Text is is converted to font glyphs
4. Glyphs are 'shaped': glyphs are laid out relative to each other depending on language rules. Gideros doesn't do that either, again it assumes latin rules. This is what HarfBuzz is doing.
5. Glyphs are rendered to screen
My code above was doing step 2 for arabic, and probably not accurately, but even with that, step 4 was missing too.
ICU used to do the same as HarfBuzz plus BiDi. They have dropped there shaping routines and integrated HarfBuzz instead, but ICU seems to be much more than just a text layout engine.
Likes: MoKaLux
When I am back I will try an example with your code and show you how I would use it.
Take it easy!
Likes: MoKaLux, talis, antix
Will BiDi be added to the normal text system too? If so, will the existing ArabicProcessing function still work?
https://deluxepixel.com
HarfBuzz .dll is around 1MB in size, which is quite a lot compared to other plugins. I can't tell for other platforms yet. It actually handle most languages, not just arabic.
I am not sure how I will implement BiDi yet, but I'll make it optional. I am looking for a lightweight implementation. So far I found ICU and FriBiDi, but I could make my own for trivial cases too. Using HarfBuzz and BiDi will make arabicProcessing obsolete, but since it will be a plugin there shouldn't be much concerns about backward compatibility.
Likes: SinisterSoft, MoKaLux, antix
See the result in attached image for two texts: each is rendered three times:
- with standard gideros functions
- with arabicProcessing being applied first
- with HarfBuzz plugin (without arabicProcessing, which is no longer necessary)
Likes: MoKaLux
Have you heard about Apple's new all-Arabic appstore?
https://www.alaraby.co.uk/english/news/2019/7/17/apple-to-launch-arabic-only-app-store-to-woo-region
Somewhat interesting
I wonder why it wasn't enough to have regular Appstore with arabic interface? It's because western developers didn't always localize their apps and games to arabic?
"What one programmer can do in one month, two programmers can do in two months." - Fred Brooks
“The more you do coding stuff, the better you get at it.” - Aristotle (322 BC)
https://play.google.com/store/apps/developer?id=razorback456
мій блог по гідерос https://simartinfo.blogspot.com
Слава Україні!
Likes: oleg, antix
Now Apple confirmed my assumptions.
Likes: MoKaLux
"What one programmer can do in one month, two programmers can do in two months." - Fred Brooks
“The more you do coding stuff, the better you get at it.” - Aristotle (322 BC)