X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=src%2Fdraw.c;h=6155d4a5bcb43ebf97fcbf9c149a698d8924e255;hb=6dd098a655551afd765159165e4b29ec9f693cb2;hp=2efae70d2e2586f4d57d71723d22aa04833a49b7;hpb=5490b251ffaf1e138295b4766226d8948a0d503f;p=m17n%2Fm17n-lib.git diff --git a/src/draw.c b/src/draw.c index 2efae70..6155d4a 100644 --- a/src/draw.c +++ b/src/draw.c @@ -17,7 +17,7 @@ You should have received a copy of the GNU Lesser General Public License along with the m17n library; if not, write to the Free - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 02111-1307, USA. */ /***en @@ -80,7 +80,7 @@ static MSymbol M_glyph_string; /* Special scripts */ -static MSymbol Minherited, Mcommon; +static MSymbol Mcommon; /* Special categories */ static MSymbol McatCc, McatCf; @@ -1112,6 +1112,7 @@ draw_background (MFrame *frame, MDrawWindow win, int x, int y, } *from_idx = *to_idx = 0; + *to_x = x; while (g->type != GLYPH_ANCHOR) { if (g->pos >= from && g->pos < to) @@ -1392,23 +1393,30 @@ find_overlapping_glyphs (MGlyphString *gstring, int *left, int *right, static int -gstring_width (MGlyphString *gstring, int from, int to, int *rbearing) +gstring_width (MGlyphString *gstring, int from, int to, + int *lbearing, int *rbearing) { MGlyph *g; int width; if (from <= gstring->from && to >= gstring->to) { + if (lbearing) + *lbearing = gstring->lbearing; if (rbearing) *rbearing = gstring->rbearing; return gstring->width; } + if (lbearing) + *lbearing = 0; if (rbearing) *rbearing = 0; for (g = MGLYPH (1), width = 0; g->type != GLYPH_ANCHOR; g++) if (g->pos >= from && g->pos < to) { + if (lbearing && width + g->lbearing < *lbearing) + *lbearing = width + g->lbearing; if (rbearing && width + g->rbearing > *rbearing) *rbearing = width + g->rbearing; width += g->width; @@ -1427,8 +1435,10 @@ render_glyph_string (MFrame *frame, MDrawWindow win, int x, int y, int from_idx, to_idx; int to_x; + if (from == to) + return; if (control->orientation_reversed) - x -= gstring->indent + gstring_width (gstring, from, to, NULL); + x -= gstring->indent + gstring_width (gstring, from, to, NULL, NULL); else x += gstring->indent; @@ -1870,7 +1880,6 @@ mdraw__init () memset (&scratch_gstring, 0, sizeof (scratch_gstring)); MLIST_INIT1 (&scratch_gstring, glyphs, 3); - Minherited = msymbol ("inherited"); Mcommon = msymbol ("common"); McatCc = msymbol ("Cc"); @@ -2245,7 +2254,7 @@ mdraw_text_extents (MFrame *frame, { MGlyphString *gstring; int y = 0; - int width, rbearing; + int width, lbearing, rbearing; ASSURE_CONTROL (control); M_CHECK_POS_X (mt, from, -1); @@ -2257,52 +2266,49 @@ mdraw_text_extents (MFrame *frame, gstring = get_gstring (frame, mt, from, to, control); if (! gstring) MERROR (MERROR_DRAW, -1); - width = gstring_width (gstring, from, to, &rbearing); + width = gstring_width (gstring, from, to, &lbearing, &rbearing); if (overall_ink_return) - { - overall_ink_return->y = - gstring->physical_ascent; - overall_ink_return->x = gstring->lbearing; - } + overall_ink_return->y = - gstring->physical_ascent; if (overall_logical_return) - { - overall_logical_return->y = - gstring->ascent; - overall_logical_return->x = 0; - } + overall_logical_return->y = - gstring->ascent; if (overall_line_return) - { - overall_line_return->y = - gstring->line_ascent; - overall_line_return->x = gstring->lbearing; - } + overall_line_return->y = - gstring->line_ascent; for (from = gstring->to; from < to; from = gstring->to) { - int this_width, this_rbearing; + int this_width, this_lbearing, this_rbearing; y += gstring->line_descent; M17N_OBJECT_UNREF (gstring->top); gstring = get_gstring (frame, mt, from, to, control); - this_width = gstring_width (gstring, from, to, &this_rbearing); + this_width = gstring_width (gstring, from, to, + &this_lbearing, &this_rbearing); y += gstring->line_ascent; if (width < this_width) width = this_width; if (rbearing < this_rbearing) rbearing = this_rbearing; + if (lbearing > this_lbearing) + lbearing = this_lbearing; } if (overall_ink_return) { - overall_ink_return->width = rbearing; + overall_ink_return->x = lbearing; + overall_ink_return->width = rbearing - lbearing; overall_ink_return->height = y + gstring->physical_descent - overall_ink_return->y; } if (overall_logical_return) { + overall_logical_return->x = 0; overall_logical_return->width = width; overall_logical_return->height = y + gstring->descent - overall_logical_return->y; } if (overall_line_return) { - overall_line_return->width = MAX (width, rbearing); + overall_line_return->x = lbearing; + overall_line_return->width = MAX (width, rbearing - lbearing); overall_line_return->height = y + gstring->line_descent - overall_line_return->y; }