[prev in list] [next in list] [prev in thread] [next in thread] 

List:       ktexteditor-devel
Subject:    patch for Kate and Indic languages
From:       Jens Herden <jens () kdewebdev ! org>
Date:       2006-05-20 19:24:49
Message-ID: 200605210224.55587.jens () kdewebdev ! org
[Download RAW message or body]

[Attachment #2 (multipart/signed)]

[Attachment #4 (multipart/mixed)]


Hi,

we have a big problem with Kate and Khmer because of the non constant 
character width. This problem must affect many other Indic languages as well!

The text renderer in Kate just adds the character width one by one to 
calculate the position of the cursor. This breaks very bad for Khmer because 
two character together can have a different width as the sum of the width of 
the two character. That means when I type Khmer the cursor is not where the 
character will appear and navigation is almost impossible. 

I made a patch to fix this and I want to have this in KDE 3.5.3, if possible. 
Can please someone look at it? 

Jens


["cursorfix.diff" (text/x-diff)]

Index: katerenderer.cpp
===================================================================
--- katerenderer.cpp	(revision 542794)
+++ katerenderer.cpp	(working copy)
@@ -635,6 +635,15 @@
           {
             // Here's where the money is...
             paint.drawText(oldXPos-xStart, y, textLine->string(), blockStartCol, nextCol-blockStartCol);
+          
+            // caculate where the text really finished, for Indic languages this 
+            // might be very different from the sum of the character width!
+            QString text = textLine->string().mid(blockStartCol, nextCol-blockStartCol);
+            QSize s = paint.fontMetrics().size(0, text);
+            xPosAfter = oldXPos + s.width();
+            // s = paint.fontMetrics().size(0, text.left(text.length() - 1));
+            // xPos = oldXPos + s.width();
+            xPos = xPosAfter - paint.fontMetrics().charWidth(text, text.length());
 
             // Draw preedit's underline
             if (isIMEdit) {
@@ -659,6 +668,15 @@
         // determine cursor X position
         if (showCursor && (cursor->col() == int(curCol)))
         {
+          // caculate where the text really finished, for Indic languages this 
+          // might be very different from the sum of the character width!
+          if (nextCol > blockStartCol)
+          {
+            QString text = textLine->string().mid(blockStartCol, nextCol-blockStartCol);
+            QSize s = paint.fontMetrics().size(0, text);
+            xPosAfter = oldXPos + s.width();
+            xPos = xPosAfter - paint.fontMetrics().charWidth(text, text.length() - 1);
+          }
           cursorVisible = true;
           cursorXPos = xPos;
           cursorMaxWidth = xPosAfter - xPos;

[Attachment #8 (application/pgp-signature)]

_______________________________________________
Ktexteditor-devel mailing list
Ktexteditor-devel@kde.org
https://mail.kde.org/mailman/listinfo/ktexteditor-devel


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic