Version: (using KDE 4.0.0) Installed from: Ubuntu Packages This patch (by Jakkapun Kwanroengjai) fixes the following problems Thai word breaking problems in KDE 4 1. The existing code uses "KLibLoder" to dynamically load libthai Thai library (if libthai is not linked since compile time). And KLibLoader requires "libthai.la", which is a) usually in the libthai-dev package of distros -- making it weird for users having to install the devel package just to use the library b) recently not shippped at all in some distros, e.g., Debian, Ubuntu, resulting in broken Thai word breaking support in KDE/KHTML. The patch changes the code to load the library using "QLibrary" which i) does not require libthai.la to work ii) allows specifying the library version number, e.g., libthai.so.0, eleminating the need to install "libthai-dev" package at all (if it looks for "libthai.so" then we will still need libthai-dev package) 2) There was a bug in this part of code (excerpted from the patch): cache->numwbrpos = th_brk((const unsigned char*) cstr.data(), cache->wbrpos, cache->allocated); //fprintf(stderr,"libthai returns with value %d\n",cache->numwbrpos); - if (cache->numwbrpos > cache->allocated) { - cache->allocated = cache->numwbrpos; + if (cache->numwbrpos >= cache->allocated) { + cache->allocated = len; cache->wbrpos = (int *)realloc(cache->wbrpos, cache->allocated*sizeof(int)); cache->numwbrpos = th_brk((const unsigned char*) cstr.data(), cache->wbrpos, cache->allocated); } We misunderstood that th_brk would return the actual number of breakable positions in the string regardless of the input parameter "cache->allocated", which denotes the size of the array cache->wbrpos in which the break positions should be stored. But after discussing with libthai developers, we realized that this return value will always be less than or equal the "cache->allocated" value. Therefore the patch will fix the algorithm to realloc the array to the string length ("len" variable) in such cases that the return value is equal to cache->allocated. Ref: [1] <a href=https://bugs.kde.org/show_bug.cgi?id=86199>Bug 86199: Thai word break support in KHTML</a>
Created attachment 23241 [details] Patch to fix Thai word break related problems in KHTML By Jakkapun Kwangroengjai
Is this really about KDE4, or KDE3? KLibLoader in KDE4 does not use libtool files.
Aow, right, okay, sorry. Maybe it was another problem (likely the library "path") with KDE4's KLibLoader. Will test more and come up with an updated patch. Thanks.
It was that PATH problem, KLibLoader didn't look for libthai in /usr/lib. The new attached patch uses KLibLoader and tries to find libthai at /usr/lib if the first attempt failed.
Created attachment 23292 [details] Fix KLibLoader - libthai + libthai th_brk return value issues
Created attachment 27098 [details] khtml thai word break using Qt 4.4 / Harfbuzz instead of libthai Use Qt 4.4 / Harfbuzz for Thai word breaking (which will in turn use libthai external library) instead of loading libthai directly in KHTML. (Patch by Thanomsub Noppaburana) Please kindly review, cheers, Pattara
Any comment with the patch? Commit it?
If this patch is still valid for current KDE, please put it on reviewboard.kde.org, otherwise it is getting lost.