[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Arabic on Zaurus/Ipaq



On Saturday 26 February 2005 11:52, Mohammed Yousif wrote:

> > It's early days, the program I have initially ported is my arabic
> > vocabulary program (it can also create a postscript/pdf file in a book
> > format of all the words). This is using PyQt and so far I have left the
> > shaping and R-to-L code in python. To get the support for tashkeel
> > (required for arabic learners) I had to hack the Qt/Embedded libraries as
> > OpenEmbedded uses qte 2.3.10 (v3 is too big for handhelds, perhaps Qt/E 4
> > will be better).
>
> Does that mean that Qt 2.x.x have some support for Unicode? I didn't think
> it had such support.
>

Yes, unicode is all there ( I attach the main tashkeel patch here as it's so 
small, take a look). I didn't want to spend all week working out why tashkeel 
doesn't work with the default code, it may be either that the support is not 
there at all or it could be because Qt/E has been compiled to work only with 
QPF fonts which may not have all the diacritical-type information in them. 
TTF support is not present in the OpenEmbedded version of qte2.3 in order to 
save memory space.

> > Looking forward it would be nice to put the shaping/bidi code entirely
> > into Qt/Embedded 2.3.10 and then to port Muhammad Yousif's qtquran.
>
> There is a pending TODO item for this:
> http://www.arabeyes.org/viewtodo.php?todoid=157
>
> But I didn't start working on it yet.

Great minds think alike (and fools seldom differ.....:-). 

>
> > I'm mentioning it here to see if anyone else would have a use for arabic
> > on this platform, otherwise I may leave things as they are (seeing as
> > they do what I mainly want to do for now).
>
> I'm very interested, please tell me if you need any help.

It would be great if you could help out. To be honest one of the hardest tasks 
is working out how Qt manages text and its rendering. I gained some 
experience in this area while working on equation display in Kayali 
(http://kayali.sourceforge.net) but the code underneath is still something of 
a mystery.

I think initially the thing to do is to port QtQuran and keep the bidi/shaping 
as a library call for now. When we've done that we can try to incorporate the 
bidi/shaping into Qt/E itself. What do you think?

How will you test the code? Do you have a zaurus? (I bought mine (SL5500) 
second-hand recently for about 100 pounds and I'm very pleased with it. The 
only down side is the short battery life). The OpenEmbedded development 
environment needs at a bare minimum 512MB RAM and really it needs over 800MB. 
It takes about 4G of hard disk space and a lot of Sabr too.

It is also possible to run everything on a PC in a virtual framebuffer but you 
will need a fair amount of RAM as I say.

Even if that is not a possibility for you, you could be a massive help in 
changing (as you mention) the XML code etc. in the QtQuran app itself.

Anyway, I hope you do join me in this effort but be warned it takes a lot of 
patience! I think from the arab/eyes/ize perspective it is important get 
arabic into these devices from as early a stage as possible. Of course Qt/E 4 
is coming along so hopefully we can then concentrate totally on the user-side 
stuff again.

wassalaam
abdulhaq



#
# Patch managed by http://www.holgerschurig.de/patcher.html
#

--- qt-2.3.10/src/kernel/qgfxraster_qws.cpp~tashkeel
+++ qt-2.3.10/src/kernel/qgfxraster_qws.cpp
@@ -1392,6 +1392,27 @@
 	int myy=y;
 	myx+=glyph.metrics->bearingx;
 	myy-=glyph.metrics->bearingy;
+
+	// HAQ hack to show arabic tashkeel (diacriticals) above 
+	// the previous character (which in reversed arabic, as it is here, is the next character)
+
+	QChar c = s[loopc];
+	if (c.unicode()	>= 0xfe70 && c.unicode() <= 0xfe7f) {
+		//printf("glyph %d bearingx %d width %d advance %d\n",
+		//	c.unicode(),glyph.metrics->bearingx, glyph.metrics->width, glyph.metrics->advance);
+
+		if (loopc < int(s.length()-1)) // if there is a following character then place this glyph over it
+		 {
+			QGlyph nextGlyph = memorymanager->lockGlyph(myfont, s[loopc+1]);
+			int nextCharWidth = nextGlyph.metrics->width;
+			myx += nextCharWidth/2 - glyph.metrics->width;
+			// pre-undo the advance in x so that the next glyph is placed over this one
+			x -= glyph.metrics->advance;
+		}
+	}
+
+	// end HAQ hack
+
 	if(glyph.metrics->width<1 || glyph.metrics->height<1
 	    || glyph.metrics->linestep==0)
 	{