KHTML Thai Word Break patchc

Pattara Kiatisevi ott at linux.thai.net
Thu May 6 17:01:01 BST 2004


Hello Lars,

On Thursday 06 May 2004 06:08, Lars Knoll wrote:
> Hi Pattara,
>
> The principle is correct, but your patch has a few problems.
>
> * Using dlopen and related is not completely portable. You should use
> KLibLoader (QLibrary in Qt only code) insstead.
> * The code leaks a lot of memory, as everytime you have to change the cache
> you allocate a QString and a QCString on the heap that are never cleaned
> up. * libkhtml is a kpart, and can get dynamically opened and closed. It
> should therefore cleanup the data it allocates when the part gets unloaded.
> * static int foo[32000] always allocates 128 kB. It's probably better to
> just allocate as much as needed

Thanks a lot for the suggestion. 

I have tested your code, there is some problems with the:

 KLibrary *lib = loader->library("libthai");

I have to change this "libthai" to "libthai.so.0" to make it work but I'm not 
sure it is a good idea to do that. A symlink /usr/lib/libthai.so 
-->  /usr/lib/libthai.so.0 didn't help.

Apart from that the word breaking function seems to work fine.

> Another small issue I can see is a performance issue. You iterate linearily
> over the list of break positions. The line breaking algorithm always will
> ask for every character if we can break here in a linear fashion. So
> storing the position isBreakable() queried in the last call should speed
> this up from O(n) to O(1).

I see. Will give a try on this.

Best regards,
Pattara

>
> I've attached a patch (compiles, but untested), that should fix all but the
> performance issue. Please have a look.
>
> Cheers,
> Lars
>
> On Wednesday 05 May 2004 18:51, Pattara Kiatisevi wrote:
> > Hello kfm-devel,
> >
> > Thai sentences have no space between words and at the end of the line it
> > is common to wrap the sentences at the word boundary.
> >
> > Here is the patch (for kdelibs/khtml/rendering/break_lines.h) to enable
> > Thai word break in KHTML (tested with kdelibs-3.2.2). It will need
> > "libthai.so". I have been testing it for a few weeks and it works so far
> > okay. Please comment.
> >
> > Libthai:
> > http://linux.thai.net/plone/TLWG/libthai/
> >
> > Regards,
> > Pattara




More information about the kfm-devel mailing list