Bug 144890 - Ability to add arbitrary Unicode characters to labels.
Summary: Ability to add arbitrary Unicode characters to labels.
Status: RESOLVED FIXED
Alias: None
Product: kst
Classification: Applications
Component: general (show other bugs)
Version: 1.x
Platform: unspecified Linux
: NOR wishlist
Target Milestone: ---
Assignee: kst
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-04-30 21:25 UTC by Duncan Hanson
Modified: 2007-05-02 01:08 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Duncan Hanson 2007-04-30 21:25:11 UTC
Version:            (using KDE KDE 3.5.5)
Installed from:    00

Duncan Hanson <duncan.hanson@gmail.com> 	Sun, Apr 1, 2007 at 5:52 PM
To: kst@kde.org
Hi All,

Has anyone else noticed that some of the label symbols don't work at all font sizes? Many of the symbols only work for the (almost illegible) 0 size. As far as I can tell this is a problem with Qt's rendering, and not with Kst. We might want to make some workarounds for popular symbols, however. E.g. I sometimes want to use capital Delta in fonts greater than 0, but the currently used character (0x394) doesn't work. I suggest we use the difference symbol (0x2206) as a substitute, it looks fairly similar. Lowercase \mu is the same story, but I don't know of any similar symbols.

I think it would also be good to be able to specify a unicode character directly in the label text. Here's a proposed patch, which introduces a new \char{} command. E.g. \char{0x2206} or \char{8710} would display the difference symbol.

Duncan.
--------------------------------

Barth Netterfield <netterfield@astro.utoronto.ca> 	Mon, Apr 2, 2007 at 6:37 AM
Reply-To: kst@kde.org
To: kst@kde.org
The bug:

I don't see this: \mu and \Delta seem to work at all sizes on my machine.
What font are you using?  What QT are you using?

The Feature:
I like the idea.
We want to make sure it is done in a standard way. Does latex have such a
concept?  If so, how is it done there?  Is \char{} used for this anywhere
else?

cbn

--------------------------------
George Staikos <staikos@kde.org> 	Mon, Apr 2, 2007 at 7:08 AM

I think this is related to the font or font libraries, not Qt
specifically.  (I haven't seen it happen here.)

Duncan Hanson <duncan.hanson@gmail.com> 	Mon, Apr 2, 2007 at 10:19 AM
----------------
Ok- I'm using Luxi Sans (my default, I think)
Qt: 3.3.7
KDE: 3.5.5-0.2.fc5 Fedora-Core

I can't get \mu or \Delta using my other fonts either, with the exception of 'fixed' (which doesn't really count.)

As for a standard unicode escape, the nearest that I can find for latex is \unichar{}, which is used by the UCS package. Another common thing is to use &#;. I think I prefer \unichar{}.

Duncan.
Comment 1 Duncan Hanson 2007-04-30 21:26:35 UTC
SVN commit 659771 by dhanson:

CCBUG:144890 for using \unicode{} in labels.

 M  +21 -8     labelparser.cpp  


--- branches/work/kst/1.5/kst/src/libkstmath/labelparser.cpp #659770:659771
@@ -464,6 +464,15 @@
         *skip = 7;
         setNormalChar(QChar(0x3A5+x), tail);
         return true;
+      } else if (txt.mid(from + 1).startsWith("nichar{")) {
+        uint charStart = from + 8;
+        uint charEnd = txt.find('}',charStart);
+        if (charEnd == -1) {
+                return false;
+        }
+        setNormalChar(QChar( (txt.mid(charStart,charEnd - charStart)).toInt(0,0)), tail);
+        *skip = charEnd - from + 1;
+        return true;
       }
       break;
 
@@ -527,16 +536,20 @@
       case 0x5e:   // ^
         dir = Chunk::Up;
       case 0x5f:   // _
-        if (ctail->vOffset != Chunk::None) {
-          if (ctail->vOffset != dir) {
-            ctail = new Chunk(ctail->prev, dir, false, true);
-          } else if (ctail->group) {
+        if (ctail->text.isEmpty() && !ctail->group) {
+          setNormalChar(c, &ctail);
+        } else {
+          if (ctail->vOffset != Chunk::None) {
+            if (ctail->vOffset != dir) {
+              ctail = new Chunk(ctail->prev, dir, false, true);
+            } else if (ctail->group) {
+              ctail = new Chunk(ctail, dir, false, true);
+            } else {
+              return 0L; // parse error - x^y^z etc
+            }
+          } else {
             ctail = new Chunk(ctail, dir, false, true);
-          } else {
-            return 0L; // parse error - x^y^z etc
           }
-        } else {
-          ctail = new Chunk(ctail, dir, false, true);
         }
         break;
       case 0x7b:   // {
Comment 2 Andrew Walker 2007-05-01 01:31:46 UTC
Duncan, your changes wiped out the fix to an earlier bug. Could you check the code in again with the previous fix reinstated.
Comment 3 Andrew Walker 2007-05-02 01:08:24 UTC
SVN commit 660205 by arwalker:

BUG:144890 Add back support for unichar without removal of earlier bug fix

 M  +11 -15    labelparser.cpp  


--- branches/work/kst/1.5/kst/src/libkstmath/labelparser.cpp #660204:660205
@@ -465,10 +465,10 @@
         setNormalChar(QChar(0x3A5+x), tail);
         return true;
       } else if (txt.mid(from + 1).startsWith("nichar{")) {
-        uint charStart = from + 8;
-        uint charEnd = txt.find('}',charStart);
+        int charStart = from + 8;
+        int charEnd = txt.find('}', charStart);
         if (charEnd == -1) {
-                return false;
+          return false;
         }
         setNormalChar(QChar( (txt.mid(charStart,charEnd - charStart)).toInt(0,0)), tail);
         *skip = charEnd - from + 1;
@@ -536,20 +536,16 @@
       case 0x5e:   // ^
         dir = Chunk::Up;
       case 0x5f:   // _
-        if (ctail->text.isEmpty() && !ctail->group) {
-          setNormalChar(c, &ctail);
-        } else {
-          if (ctail->vOffset != Chunk::None) {
-            if (ctail->vOffset != dir) {
-              ctail = new Chunk(ctail->prev, dir, false, true);
-            } else if (ctail->group) {
-              ctail = new Chunk(ctail, dir, false, true);
-            } else {
-              return 0L; // parse error - x^y^z etc
-            }
-          } else {
+        if (ctail->vOffset != Chunk::None) {
+          if (ctail->vOffset != dir) {
+            ctail = new Chunk(ctail->prev, dir, false, true);
+          } else if (ctail->group) {
             ctail = new Chunk(ctail, dir, false, true);
+          } else {
+            return 0L; // parse error - x^y^z etc
           }
+        } else {
+          ctail = new Chunk(ctail, dir, false, true);
         }
         break;
       case 0x7b:   // {