[liblouis-liblouisxml] compbrlAtCursor mode with Chinese braille tables

  • From: James Teh <jamie@xxxxxxxxxxxx>
  • To: liblouis/liblouisxml mailing list <liblouis-liblouisxml@xxxxxxxxxxxxx>
  • Date: Thu, 05 Aug 2010 19:55:34 +1000

Hi all,

The Chinese braille tables (and possibly other tables as well) simply define signs for individual unicode characters using the "sign" opcode. There are no contractions, etc. A single sign may be several cells long in braille. For example:
sign \x9019 14-15-6
This unfortunately presents problems with cursorPos when the compbrlAtCursor mode is set. For example, if you have two \x9019 characters and set the input cursorPos to 1 with compbrlAtCursor, the resultant output cursorPos is 1 instead of 3.

Of course, the work around is to avoid using compbrlAtCursor. However, in NVDA, this is enabled by default and users shouldn't be expected to change this to work around this issue.

The problem here is that liblouis is assuming that output will always be a 1-to-1 mapping between input and output within compbrlStart and compbrlEnd. The attached patch fixes this. It works for me, but I'd appreciate a quick glance from John.

Jamie

--
James Teh
Vice President
NV Access Inc, ABN 61773362390
Email: jamie@xxxxxxxxxxxx
Web site: http://www.nvaccess.org/
Index: liblouis/lou_translateString.c
===================================================================
--- liblouis/lou_translateString.c      (revision 371)
+++ liblouis/lou_translateString.c      (working copy)
@@ -401,7 +401,6 @@ for_updatePositions (const widechar * outChars, in
        {
          if (src >= compbrlStart)
            {
-             cursorPosition = dest + cursorPosition - compbrlStart;
              cursorStatus = 2;
              return (doCompTrans (compbrlStart, compbrlEnd));
            }
@@ -418,6 +417,8 @@ for_updatePositions (const widechar * outChars, in
          cursorStatus = 1;
        }
     }
+  else if (cursorStatus == 2 && cursorPosition == src)
+    cursorPosition = dest;
   if (inputPositions != NULL || outputPositions != NULL)
     {
       if (outLength <= inLength)

Other related posts: