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

Re: miniBidi



On Saturday 05 March 2005 21:24, Ahmad Khalifa wrote:

>
> Try this...
>
> #define BLOCKTYPE QString
> #define CHARTYPE QChar
> #define GETCHAR(from,i) from[i]
>

I'll try this tomorrow, in the mean time I can confirm that something odd is 
happening in the shaping, I attach a simple program that uses minibidi and 
this is the output (compile with
 gcc qbidi.cpp -L/usr/qt/3/lib -lqt -I/usr/qt/3/include
)
:

: char 0 is 643
: char 1 is 650
: char 2 is 62a
: char 3 is 627
: char 4 is 628
: char 0 is fe8f
: char 1 is fe8e
: char 2 is fe98
: char 3 is 4082
: char 4 is fedb

There's definitely something odd going on with the kasra
wassalaam
abdulhaq
#include "minibidi.c"
#include "qstring.h"

QString& qApplyBidi(const QString& s) {
    static QString news("");
	//convert to utf16 zero-terminated
        int loopc;
	int slength = sizeof(unsigned short) * (s.length() + 1);

	unsigned short* sutf16 = (unsigned short*)malloc(slength);
	unsigned short* sutf16s = (unsigned short*)malloc(slength);
	
	for( loopc=0; loopc < int(s.length()); loopc++ ) {
	  sutf16[loopc] = s[loopc].unicode();
	}

	sutf16[s.length()] = 0;

	doShape(sutf16, sutf16s,0,s.length());
	sutf16s[s.length()] = 0;

	doBidi(sutf16s, s.length(),0,0,0);
	sutf16s[s.length()] = 0;

	news = "";
	for( loopc=0; sutf16s[loopc] != 0; loopc++ ) {
	  QChar newChar((short) sutf16s[loopc]);
	  news = news + newChar;
	}

	free(sutf16);
	free(sutf16s);

	return news;

}

int main() {
	QString in = QString(QChar((short)0x643)) + QChar((short)0x650) + \
		QChar((short)0x62a) + QChar((short)0x627) + QChar((short)0x628);
	for( int loopc=0; loopc < int(in.length()); loopc++ ) {
		printf(": char %d is %x\n",loopc,in[loopc].unicode());
	}
	QString out = qApplyBidi(in);
	for( int loopc=0; loopc < int(out.length()); loopc++ ) {
		printf(": char %d is %x\n",loopc,out[loopc].unicode());
	}

}