[PATCH v2 1/3] Handle CJK wide glyph rendering

Bill Spitzak spitzak at gmail.com
Thu Jul 18 11:23:27 PDT 2013

Peng Wu wrote:
> On Wed, 2013-07-17 at 09:53 -0700, Bill Spitzak wrote:
>> For a demo 
>> client I would skip trying to interpret wcwidth on incoming text,
>> just 
>> act like each glyph takes one character cell.
> But this will cause rendering problems when display CJK characters.
> The CJK glyphs will overlap each other.

I think I am not explaining it correctly.

Right now the code does something like this to draw:

   char* string = the_line_to_draw;
   x = 0;
   while (*string) {
     draw_character(*string++, x, y);
     x += character_width;

And to figure out where to draw an underscore or cursor it does:

int where_is_position_n(int n) {
   return n * character_width;

I propose the drawing code be changed to something like this:

   char* string = the_line_to_draw;
   cairo_draw_text_at(x, y, string);

And this:

int where_is_position_n(int n, char* string) {
   return cairo_text_width(string, n);

More information about the wayland-devel mailing list