Page MenuHome

Write Arabic Text on Blender 2.8
Open, Needs Information from UserPublic

Description

This addon allow users to write text in Arabic

How to use:

  • Add/Select a Text object
  • Activate this addon by pressing CTRL+F1 on the keyborad OR by executing the operator labeled "Write Arabic Text"
  • Edit text as you do usually by entering edit mode and writing the text you want

Old File:

Details

Type
Patch

Related Objects

Event Timeline

Rasheed mh (alfanak) updated the task description. (Show Details)

Personally I'd love to have a design doc somewhere where we can explore what might be needed to properly support right-to-left languages like Arabic, Farsi, Hebrew, Urdu, etc.

This code is not the right/standard way to implment text writing support.
I have no documentation for that, and i don't know the right way fonts works, or how other languages are written.

If you have a specific question about the code itself i would be glad to help.

The problem you describe is that Blender does not support RTL language.

Brendon Murphy (meta-androcto) triaged this task as Needs Information from User priority.

hi, does this work as expected? or are limitations in Blender preventing it from working to a desired result?

@Brendon Murphy (meta-androcto) - A summary as best as I can:

@Rasheed mh (alfanak) wrote this sweet addon that helps users enter Arabic text for text object. Runs without errors, seems to do what it purports to do. He commented that this is necessarily complex because we don't have any RTL supporting-code. The complexity in this case isn't just adding and editing text RTL but also in dealing with how many Arabic character glyphs join with neighboring glyphs.

I butted in, off topic, to say that I'd (also) love a longer-standing design document for language issues like this. Have native speakers help us triage what things might be needed to better support such languages as Arabic, Farsi, Hebrew, Urdu, etc. Things like right-to-left text entry (number entry remains left-to-right), which is the topic of this ticket. But also issues around right-to-left layout (for example menus would have items right-aligned and submenus open to the left), right-to-left widget placement, etc. We could even quite easily support different number systems like East Arabic, Bengali, Devanagari, Malayalam, etc. Different characters for radix point (baseline decimal, middle dot, comma, Arabic decimal separator), etc.

I think my (off-topic) comment prompted the original author to mention that what he has done is not really the right way for a program to do this, but is just a way to get this one thing done. I think his comment, and our lack of users with Arabic experience is what has prompted this to be set to "Needs Information from User"

hi, does this work as expected? or are limitations in Blender preventing it from working to a desired result?

I think it should work as expected (as described at least) but in a very annoying way for the user, a simple task like entering some text (maybe once in a very long time) does not need to be complicated and take a lot of steps to be done.

One of the potential problems is when a user uses this add-on before changing the text font, he will not see any characters while typing because the default font file does not contain Arabic characters, which make him thinking that the add-on is not working for him.
Using a Unicode font that contains Arabic characters for a Blender text object as a default font would help a lot.

For the code, if you provide a method to set the cursor position at a specific index in the module "bpy.ops.font", will makes things easier.
I don't remember what else can help with the code because I wrote this add-on long time ago and for now I'm working on a completely different thing...

hi, thanks for the reply. thanks for the detailed information. I don't think in it's current form we could add to Blender. I do see the usefulness.

Using a Unicode font that contains Arabic characters for a Blender text object as a default font would help a lot.

I wonder if you could include said font in the addon? I'n not sure if that would even work.. ( If the addon had it's own folder and init file and font file included )
What do you think? do you have time for this?
Pleas let me know how to proceed, I am closing tasks that are not going to make it into Blender 2.8 atm and I'm looking to solve or archive this.

Using a Unicode font that contains Arabic characters for a Blender text object as a default font would help a lot.

Just to clarify this...

By default everything in Blender uses a (small) font that ships with called "bfont.ttf" (I think). That font does not contain Arabic glyphs.

But the moment you click the "Translation" checkbox (Edit/ Preferences / Interface), and do nothing else, it will immediately start using a larger on-disk font (droidsans) that also ships with Blender. That font does contain the needed Arabic glyphs. This detail, that a different and better font comes with Blender but is only used when you click that checkmark, is a bit obscure. There are good arguments to just use that font by default even though it would have a larger memory footprint.

This comment was removed by Harley Acheson (harley).

Have to walk back something here...

@Rasheed mh (alfanak) specifically mentioned "Arabic characters for a Blender text object". What I was talking about above affects all text in the interface of Blender. So as soon as you click that "Translation" checkmark the larger and better font is what is used for the interface. Unfortunately even doing this does not change the default font for text objects, which seems to stay using "Bfont".

I wonder if you could include said font in the addon? I'n not sure if that would even work.. ( If the addon had it's own folder and init file and font file included )

I will try that.

Have to walk back something here...
@Rasheed mh (alfanak) specifically mentioned "Arabic characters for a Blender text object". What I was talking about above affects all text in the interface of Blender. So as soon as you click that "Translation" checkmark the larger and better font is what is used for the interface. Unfortunately even doing this does not change the default font for text objects, which seems to stay using "Bfont".

I think, Bfont itself is a Unicode font that contains Arabic characters, but its partially loaded into memory. I'm not sure but maybe Bfont is loaded from the file "~blender2.8/2.80/datafiles/fonts/bmonofont-i18n.ttf.gz" which actually contains Arabic and Hebrew characters, BUT its just a guess, i have no idea about blender source code.

Thank you.

I wonder if you could include said font in the addon? I'n not sure if that would even work.. ( If the addon had it's own folder and init file and font file included )

I will try that.

I added a font (the one that come with blender) to the add-on folder. The font is directly loaded and assigned to the 3D text Object when the add-on is initialized.
I also fixed the mixture of English and Arabic characters, so English characters does not appear from right to left anymore, still needs a bit of improvements though.

Jaggz H (jaggz) signed these changes with MFA.EditedWed, Aug 14, 11:00 AM
Jaggz H (jaggz) added a subscriber: Jaggz H (jaggz).

Just an FYI:
harfbuzz is the most common library for handling font shaping, used in "Android, Chrome, ChromeOS, Firefox, GNOME, GTK+, KDE, LibreOffice, OpenJDK, PlayStation, Qt, XeTeX, and other places."
Their manual "what-is-harfbuzz.html" states, "HarfBuzz can properly shape all of the world's major writing systems."
https://harfbuzz.github.io/getting-started.html

Another FYI:
bfont is lacking, but bmonofont and droidsans, included with 2.8, do have Arabic glyphs. It seems their joining rules are not that complete, however (see fail example below), A script could handle some of these issues, but in the future, if we're going to handle international languages (right-left, up-down, etc.) we might want to go with harfbuzz, which not only chooses the appropriate glyphs, but returns information on their positioning. It would need to be handled in C. For now, with a script like the above, someone would need to pick a different font, and then could set about their typing, and that might be sufficient for the time being.

For what it's worth, the most complete and capable Arabic font I've found is readily available on the web, me_quran.ttf, and possibly its [few] variants. (It is specified as free for "personal and non-commercial use" however).
Here's an example of a place where it succeeds in my web browser:


And here's bfontmono i18n's version, being unhappy in the web browser, even with harfbuzz trying to make it work out:

(droidsans seems about the same quality as bfont, with regard to my cursory examination of its Arabic rule-handling.)

Please bear in mind, most Arabic writing is not as demanding as the above examples. The basic joining of letters and perhaps basic vowel handling would suffice, so such a script would work. This is true with other languages too, like Persian (and its variants) and Urdu, which use modified Arabic alphabets (but are otherwise different languages), as well as Hebrew (ie. not putting the various diacritics), etc. (Harfbuzz would handle all that though).

A core developer does have a current plan to incorporate Harfbuzz, but not aware of the how quickly he is hoping to do so.

This was attempted in the past, notably here:

https://developer.blender.org/D1809

But I think we need more native speakers, who are also developers, who can offer assistance with such things over a long term.

Pardon me, I have to correct something. bfont does NOT have the Arabic glyphs.
Once a font is loaded, can Python access its glyph data, so if they're outright missing (without placeholder glyphs) an addon script can warn?

bfont range of common Arabic letters:

bfontmono and droidsans:


I might make the change in my original post so as not to waste someone's time when they read it.

You might want to check this: Raqm library

Raqm is a small library that encapsulates the logic for complex text layout and provides a convenient API.

It currently provides bidirectional text support (using FriBiDi), shaping (using HarfBuzz), and proper script itemization. As a result, Raqm can support most writing systems covered by Unicode.