+ if (src->type == COMPOSITE_GLYPH)
+ {
+ struct composition *cmp;
+ Lisp_Object gstring;
+ int i;
+
+ nbytes = buf - encode_terminal_src;
+ if (src->u.cmp.automatic)
+ {
+ gstring = composition_gstring_from_id (src->u.cmp.id);
+ required = src->u.cmp.to + 1 - src->u.cmp.from;
+ }
+ else
+ {
+ cmp = composition_table[src->u.cmp.id];
+ required = MAX_MULTIBYTE_LENGTH * cmp->glyph_len;
+ }
+
+ if (encode_terminal_src_size < nbytes + required)
+ {
+ encode_terminal_src_size = nbytes + required;
+ encode_terminal_src = xrealloc (encode_terminal_src,
+ encode_terminal_src_size);
+ buf = encode_terminal_src + nbytes;
+ }
+
+ if (src->u.cmp.automatic)
+ for (i = src->u.cmp.from; i <= src->u.cmp.to; i++)
+ {
+ Lisp_Object g = LGSTRING_GLYPH (gstring, i);
+ int c = LGLYPH_CHAR (g);
+
+ if (! char_charset (c, charset_list, NULL))
+ c = '?';
+ buf += CHAR_STRING (c, buf);
+ nchars++;
+ }
+ else
+ for (i = 0; i < cmp->glyph_len; i++)
+ {
+ int c = COMPOSITION_GLYPH (cmp, i);
+
+ if (c == '\t')
+ continue;
+ if (char_charset (c, charset_list, NULL))
+ {
+ if (CHAR_WIDTH (c) == 0
+ && i > 0 && COMPOSITION_GLYPH (cmp, i - 1) == '\t')
+ /* Should be left-padded */
+ {
+ buf += CHAR_STRING (' ', buf);
+ nchars++;
+ }
+ }
+ else
+ c = '?';
+ buf += CHAR_STRING (c, buf);
+ nchars++;
+ }
+ }