KHTML Thai Word Break patchc
Lars Knoll
lars at trolltech.com
Wed May 5 22:08:23 BST 2004
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
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'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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: khtml_thaibreaks.diff
Type: text/x-diff
Size: 5006 bytes
Desc: not available
URL: <https://mail.kde.org/mailman/private/kfm-devel/attachments/20040505/aa92da6c/attachment.diff>
More information about the kfm-devel
mailing list