DO NOT REPLY TO THIS MESSAGE.  INSTEAD, POST ANY RESPONSES TO THE LINK BELOW.

[STR New]

Link: http://www.fltk.org/str.php?L2158
Version: 1.3-current


I think that I might have isolated the problem in this particular
case, but I'm not sure whether any issues might pop up elsewhere
in Fl_Text_Display and Fl_Text_Buffer handling.

<pre>
int Fl_Text_Buffer::character_width(char c, int indent, int tabDist, char
nullSubsChar) {
  /* Note, this code must parallel that in Fl_Text_Buffer::ExpandCharacter
*/
  if (c == '\t')
    return tabDist - (indent % tabDist);
  else if (((unsigned char) c) <= 31)
    return strlen(ControlCodeTable[ (unsigned char) c ]) + 2;
  else if (c == 127)
    return 5;
  else if (c == nullSubsChar)
    return 5;
  else if ((c & 0x80) && !(c & 0x40))
    return 0;
  else if (c & 0x80) {
    return fl_utf8len(c);
  }
  return 1;
}
</pre>

I think that the final call to fl_utf8len() is wrong in this case.
A Unicode character represented as a UTF-8 byte sequence consists
of a header byte that indicates how many bytes are in the sequence,
and one or more non-header bytes. fl_utf8len() returns the number
of bytes in the sequence if passed the header byte, and zero for
the non-header bytes.

The code above appears to correctly handle tabs, ASCII control and
"nul" characters, and the UTF-8 non-header byte. However, instead
of treating the UTF-8 header byte as indicating that the UTF-8 byte
sequence expands to ONE character, it expands it to the number of
bytes in the sequence.

Changing "fl_utf8len(c)" to "1" in the above solves this problem.

The Fl_Text_Display and FL_Text_Buffer code is hard to understand,
and it may be that there are other areas where similar logic needs
to be investigated.

D.


Link: http://www.fltk.org/str.php?L2158
Version: 1.3-current

_______________________________________________
fltk-bugs mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-bugs

Reply via email to