Remove restriction on the number of glyphs in one composition.

This commit is contained in:
Kenichi Handa 2010-09-27 14:27:28 +09:00
parent 1114abdb3d
commit 4be9765d4b
5 changed files with 75 additions and 36 deletions

View file

@ -1,3 +1,29 @@
2010-09-27 Kenichi Handa <handa@m17n.org>
These changes are to remove restriction on the number of glyphs in
one composition.
* dispextern.h (struct glyph): Change the member "slice" to union.
Remove u.cmp.from and u.cmp.to. Give more bits to u.cmp.id.
(GLYPH_SLICE_EQUAL_P): Adjusted for the above change.
* dispnew.c (buffer_posn_from_coords): Use glyph->slice.img
instead of glyph->slice.
(marginal_area_string): Likewise.
* term.c (encode_terminal_code): Use glyph->slice.cmp instead of
glyph->u.cmp.
(append_composite_glyph): Likewise.
* xdisp.c (dump_glyph): Use glyph->slice.cmp instead of
glyph->u.cmp.
(fill_gstring_glyph_string, x_get_glyph_overhangs)
(append_composite_glyph): Likewise.
(fill_image_glyph_string): Use glyph->slice.img instead of
glyph->slice.
(append_glyph, produce_image_glyph, append_stretch_glyph)
(note_mouse_highlight): Likewise.
2010-09-22 Kenichi Handa <handa@m17n.org>
* xdisp.c (compute_stop_pos): Call composition_compute_stop_pos

View file

@ -394,7 +394,15 @@ struct glyph
w32_char_font_type. Otherwise it equals FONT_TYPE_UNKNOWN. */
unsigned font_type : 3;
struct glyph_slice slice;
/* A union of sub-structures for different glyph types. */
union
{
/* Metrics of a partial glyph of an image (type == IMAGE_GLYPH). */
struct glyph_slice img;
/* Start and end indices of glyphs of a graphme cluster of a
composition (type == COMPOSITE_GLYPH). */
struct { int from, to; } cmp;
} slice;
/* A union of sub-structures for different glyph types. */
union
@ -402,16 +410,13 @@ struct glyph
/* Character code for character glyphs (type == CHAR_GLYPH). */
unsigned ch;
/* Sub-structures for type == COMPOSITION_GLYPH. */
/* Sub-structures for type == COMPOSITE_GLYPH. */
struct
{
/* Flag to tell if the composition is automatic or not. */
unsigned automatic : 1;
/* ID of the composition. */
unsigned id : 23;
/* Start and end indices of glyphs of the composition. */
unsigned from : 4;
unsigned to : 4;
unsigned id : 31;
} cmp;
/* Image ID for image glyphs (type == IMAGE_GLYPH). */
@ -443,13 +448,21 @@ struct glyph
#define CHAR_GLYPH_SPACE_P(GLYPH) \
((GLYPH).u.ch == SPACEGLYPH && (GLYPH).face_id == DEFAULT_FACE_ID)
/* Are glyph slices of glyphs *X and *Y equal */
/* Are glyph slices of glyphs *X and *Y equal? It assumes that both
glyphs have the same type.
#define GLYPH_SLICE_EQUAL_P(X, Y) \
((X)->slice.x == (Y)->slice.x \
&& (X)->slice.y == (Y)->slice.y \
&& (X)->slice.width == (Y)->slice.width \
&& (X)->slice.height == (Y)->slice.height)
Note: for composition glyphs, we don't have to compare slice.cmp.to
because they should be the same if and only if slice.cmp.from are
the same. */
#define GLYPH_SLICE_EQUAL_P(X, Y) \
((X)->type == IMAGE_GLYPH \
? ((X)->slice.img.x == (Y)->slice.img.x \
&& (X)->slice.img.y == (Y)->slice.img.y \
&& (X)->slice.img.width == (Y)->slice.img.width \
&& (X)->slice.img.height == (Y)->slice.img.height) \
: ((X)->type != COMPOSITE_GLYPH \
|| (X)->slice.cmp.from == (Y)->slice.cmp.from))
/* Are glyphs *X and *Y displayed equal? */

View file

@ -5457,8 +5457,8 @@ buffer_posn_from_coords (struct window *w, int *x, int *y, struct display_pos *p
if (img)
{
*dy -= row->ascent - glyph->ascent;
*dx += glyph->slice.x;
*dy += glyph->slice.y;
*dx += glyph->slice.img.x;
*dy += glyph->slice.img.y;
/* Image slices positions are still relative to the entire image */
*width = img->width;
*height = img->height;
@ -5620,8 +5620,8 @@ marginal_area_string (struct window *w, enum window_part part, int *x, int *y, i
if (img != NULL)
*object = img->spec;
y0 -= row->ascent - glyph->ascent;
x0 += glyph->slice.x;
y0 += glyph->slice.y;
x0 += glyph->slice.img.x;
y0 += glyph->slice.img.y;
}
#endif
}

View file

@ -598,7 +598,7 @@ encode_terminal_code (struct glyph *src, int src_len, struct coding_system *codi
if (src->u.cmp.automatic)
{
gstring = composition_gstring_from_id (src->u.cmp.id);
required = src->u.cmp.to + 1 - src->u.cmp.from;
required = src->slice.cmp.to + 1 - src->slice.cmp.from;
}
else
{
@ -615,7 +615,7 @@ encode_terminal_code (struct glyph *src, int src_len, struct coding_system *codi
}
if (src->u.cmp.automatic)
for (i = src->u.cmp.from; i <= src->u.cmp.to; i++)
for (i = src->slice.cmp.from; i <= src->slice.cmp.to; i++)
{
Lisp_Object g = LGSTRING_GLYPH (gstring, i);
int c = LGLYPH_CHAR (g);
@ -1795,8 +1795,8 @@ append_composite_glyph (struct it *it)
{
glyph->u.cmp.automatic = 1;
glyph->u.cmp.id = it->cmp_it.id;
glyph->u.cmp.from = it->cmp_it.from;
glyph->u.cmp.to = it->cmp_it.to - 1;
glyph->slice.cmp.from = it->cmp_it.from;
glyph->slice.cmp.to = it->cmp_it.to - 1;
}
glyph->face_id = it->face_id;

View file

@ -16214,7 +16214,7 @@ dump_glyph (row, glyph, area)
if (glyph->u.cmp.automatic)
fprintf (stderr,
"[%d-%d]",
glyph->u.cmp.from, glyph->u.cmp.to);
glyph->slice.cmp.from, glyph->slice.cmp.to);
fprintf (stderr, " . %4d %1.1d%1.1d\n",
glyph->face_id,
glyph->left_box_line_p,
@ -20600,8 +20600,8 @@ fill_gstring_glyph_string (struct glyph_string *s, int face_id,
glyph = s->row->glyphs[s->area] + start;
last = s->row->glyphs[s->area] + end;
s->cmp_id = glyph->u.cmp.id;
s->cmp_from = glyph->u.cmp.from;
s->cmp_to = glyph->u.cmp.to + 1;
s->cmp_from = glyph->slice.cmp.from;
s->cmp_to = glyph->slice.cmp.to + 1;
s->face = FACE_FROM_ID (s->f, face_id);
lgstring = composition_gstring_from_id (s->cmp_id);
s->font = XFONT_OBJECT (LGSTRING_FONT (lgstring));
@ -20609,8 +20609,8 @@ fill_gstring_glyph_string (struct glyph_string *s, int face_id,
while (glyph < last
&& glyph->u.cmp.automatic
&& glyph->u.cmp.id == s->cmp_id
&& s->cmp_to == glyph->u.cmp.from)
s->cmp_to = (glyph++)->u.cmp.to + 1;
&& s->cmp_to == glyph->slice.cmp.from)
s->cmp_to = (glyph++)->slice.cmp.to + 1;
for (i = s->cmp_from; i < s->cmp_to; i++)
{
@ -20700,7 +20700,7 @@ fill_image_glyph_string (struct glyph_string *s)
xassert (s->first_glyph->type == IMAGE_GLYPH);
s->img = IMAGE_FROM_ID (s->f, s->first_glyph->u.img_id);
xassert (s->img);
s->slice = s->first_glyph->slice;
s->slice = s->first_glyph->slice.img;
s->face = FACE_FROM_ID (s->f, s->first_glyph->face_id);
s->font = s->face->font;
s->width = s->first_glyph->pixel_width;
@ -20806,8 +20806,8 @@ x_get_glyph_overhangs (struct glyph *glyph, struct frame *f, int *left, int *rig
Lisp_Object gstring = composition_gstring_from_id (glyph->u.cmp.id);
struct font_metrics metrics;
composition_gstring_width (gstring, glyph->u.cmp.from,
glyph->u.cmp.to + 1, &metrics);
composition_gstring_width (gstring, glyph->slice.cmp.from,
glyph->slice.cmp.to + 1, &metrics);
if (metrics.rbearing > metrics.width)
*right = metrics.rbearing - metrics.width;
if (metrics.lbearing < 0)
@ -21512,7 +21512,7 @@ append_glyph (struct it *it)
glyph->glyph_not_available_p = it->glyph_not_available_p;
glyph->face_id = it->face_id;
glyph->u.ch = it->char_to_display;
glyph->slice = null_glyph_slice;
glyph->slice.img = null_glyph_slice;
glyph->font_type = FONT_TYPE_UNKNOWN;
if (it->bidi_p)
{
@ -21569,13 +21569,14 @@ append_composite_glyph (struct it *it)
{
glyph->u.cmp.automatic = 0;
glyph->u.cmp.id = it->cmp_it.id;
glyph->slice.cmp.from = glyph->slice.cmp.to = 0;
}
else
{
glyph->u.cmp.automatic = 1;
glyph->u.cmp.id = it->cmp_it.id;
glyph->u.cmp.from = it->cmp_it.from;
glyph->u.cmp.to = it->cmp_it.to - 1;
glyph->slice.cmp.from = it->cmp_it.from;
glyph->slice.cmp.to = it->cmp_it.to - 1;
}
glyph->avoid_cursor_p = it->avoid_cursor_p;
glyph->multibyte_p = it->multibyte_p;
@ -21586,7 +21587,6 @@ append_composite_glyph (struct it *it)
glyph->padding_p = 0;
glyph->glyph_not_available_p = 0;
glyph->face_id = it->face_id;
glyph->slice = null_glyph_slice;
glyph->font_type = FONT_TYPE_UNKNOWN;
if (it->bidi_p)
{
@ -21765,7 +21765,7 @@ produce_image_glyph (struct it *it)
glyph->glyph_not_available_p = 0;
glyph->face_id = it->face_id;
glyph->u.img_id = img->id;
glyph->slice = slice;
glyph->slice.img = slice;
glyph->font_type = FONT_TYPE_UNKNOWN;
if (it->bidi_p)
{
@ -21826,7 +21826,7 @@ append_stretch_glyph (struct it *it, Lisp_Object object,
glyph->face_id = it->face_id;
glyph->u.stretch.ascent = ascent;
glyph->u.stretch.height = height;
glyph->slice = null_glyph_slice;
glyph->slice.img = null_glyph_slice;
glyph->font_type = FONT_TYPE_UNKNOWN;
if (it->bidi_p)
{
@ -24513,8 +24513,8 @@ note_mouse_highlight (struct frame *f, int x, int y)
if ((image_map = Fplist_get (XCDR (img->spec), QCmap),
!NILP (image_map))
&& (hotspot = find_hot_spot (image_map,
glyph->slice.x + dx,
glyph->slice.y + dy),
glyph->slice.img.x + dx,
glyph->slice.img.y + dy),
CONSP (hotspot))
&& (hotspot = XCDR (hotspot), CONSP (hotspot)))
{