diff options
| author | Kenichi Handa | 2004-01-23 08:47:18 +0000 |
|---|---|---|
| committer | Kenichi Handa | 2004-01-23 08:47:18 +0000 |
| commit | 993651d1a07fc61db10b29d47417c4d99dfc1ff1 (patch) | |
| tree | e90e80a8d2b6e5576fda6c0fef192fadd4d809e4 /src | |
| parent | 980a8c09cc6f2c1cc660057ceecba3451461032d (diff) | |
| download | emacs-993651d1a07fc61db10b29d47417c4d99dfc1ff1.tar.gz emacs-993651d1a07fc61db10b29d47417c4d99dfc1ff1.zip | |
(move_it_to): Optimize for the case (op & MOVE_TO_Y).
(x_get_glyph_overhangs): Handle a composition glyph.
(x_produce_glyphs): Setup lbearing and rbreaing for a composition
glyph.
Diffstat (limited to 'src')
| -rw-r--r-- | src/xdisp.c | 81 |
1 files changed, 70 insertions, 11 deletions
diff --git a/src/xdisp.c b/src/xdisp.c index 7a1f0d4b573..6b814c0e55a 100644 --- a/src/xdisp.c +++ b/src/xdisp.c | |||
| @@ -5838,6 +5838,16 @@ move_it_to (it, to_charpos, to_x, to_y, to_vpos, op) | |||
| 5838 | the line. */ | 5838 | the line. */ |
| 5839 | if (skip == MOVE_X_REACHED) | 5839 | if (skip == MOVE_X_REACHED) |
| 5840 | { | 5840 | { |
| 5841 | /* Wait! We can conclude that TO_Y is in the line if | ||
| 5842 | the already scanned glyphs make the line tall enough | ||
| 5843 | because further scanning doesn't make it shorter. */ | ||
| 5844 | line_height = it->max_ascent + it->max_descent; | ||
| 5845 | if (to_y >= it->current_y | ||
| 5846 | && to_y < it->current_y + line_height) | ||
| 5847 | { | ||
| 5848 | reached = 6; | ||
| 5849 | break; | ||
| 5850 | } | ||
| 5841 | it_backup = *it; | 5851 | it_backup = *it; |
| 5842 | TRACE_MOVE ((stderr, "move_it: from %d\n", IT_CHARPOS (*it))); | 5852 | TRACE_MOVE ((stderr, "move_it: from %d\n", IT_CHARPOS (*it))); |
| 5843 | skip2 = move_it_in_display_line_to (it, to_charpos, -1, | 5853 | skip2 = move_it_in_display_line_to (it, to_charpos, -1, |
| @@ -16921,6 +16931,13 @@ x_get_glyph_overhangs (glyph, f, left, right) | |||
| 16921 | *left = -pcm->lbearing; | 16931 | *left = -pcm->lbearing; |
| 16922 | } | 16932 | } |
| 16923 | } | 16933 | } |
| 16934 | else if (glyph->type == COMPOSITE_GLYPH) | ||
| 16935 | { | ||
| 16936 | struct composition *cmp = composition_table[glyph->u.cmp_id]; | ||
| 16937 | |||
| 16938 | *right = cmp->rbearing - cmp->pixel_width; | ||
| 16939 | *left = - cmp->lbearing; | ||
| 16940 | } | ||
| 16924 | } | 16941 | } |
| 16925 | 16942 | ||
| 16926 | 16943 | ||
| @@ -18198,8 +18215,8 @@ x_produce_glyphs (it) | |||
| 18198 | now. Theoretically, we have to check all fonts for the | 18215 | now. Theoretically, we have to check all fonts for the |
| 18199 | glyphs, but that requires much time and memory space. So, | 18216 | glyphs, but that requires much time and memory space. So, |
| 18200 | here we check only the font of the first glyph. This leads | 18217 | here we check only the font of the first glyph. This leads |
| 18201 | to incorrect display very rarely, and C-l (recenter) can | 18218 | to incorrect display, but it's very rare, and C-l (recenter) |
| 18202 | correct the display anyway. */ | 18219 | can correct the display anyway. */ |
| 18203 | if (cmp->font != (void *) font) | 18220 | if (cmp->font != (void *) font) |
| 18204 | { | 18221 | { |
| 18205 | /* Ascent and descent of the font of the first character of | 18222 | /* Ascent and descent of the font of the first character of |
| @@ -18208,8 +18225,10 @@ x_produce_glyphs (it) | |||
| 18208 | them respectively. */ | 18225 | them respectively. */ |
| 18209 | int font_ascent = FONT_BASE (font) + boff; | 18226 | int font_ascent = FONT_BASE (font) + boff; |
| 18210 | int font_descent = FONT_DESCENT (font) - boff; | 18227 | int font_descent = FONT_DESCENT (font) - boff; |
| 18228 | int font_height = FONT_HEIGHT (font); | ||
| 18211 | /* Bounding box of the overall glyphs. */ | 18229 | /* Bounding box of the overall glyphs. */ |
| 18212 | int leftmost, rightmost, lowest, highest; | 18230 | int leftmost, rightmost, lowest, highest; |
| 18231 | int lbearing, rbearing; | ||
| 18213 | int i, width, ascent, descent; | 18232 | int i, width, ascent, descent; |
| 18214 | 18233 | ||
| 18215 | cmp->font = (void *) font; | 18234 | cmp->font = (void *) font; |
| @@ -18222,12 +18241,20 @@ x_produce_glyphs (it) | |||
| 18222 | width = pcm->width; | 18241 | width = pcm->width; |
| 18223 | ascent = pcm->ascent; | 18242 | ascent = pcm->ascent; |
| 18224 | descent = pcm->descent; | 18243 | descent = pcm->descent; |
| 18244 | lbearing = pcm->lbearing; | ||
| 18245 | if (lbearing > 0) | ||
| 18246 | lbearing = 0; | ||
| 18247 | rbearing = pcm->rbearing; | ||
| 18248 | if (rbearing < width) | ||
| 18249 | rbearing = width; | ||
| 18225 | } | 18250 | } |
| 18226 | else | 18251 | else |
| 18227 | { | 18252 | { |
| 18228 | width = FONT_WIDTH (font); | 18253 | width = FONT_WIDTH (font); |
| 18229 | ascent = FONT_BASE (font); | 18254 | ascent = FONT_BASE (font); |
| 18230 | descent = FONT_DESCENT (font); | 18255 | descent = FONT_DESCENT (font); |
| 18256 | lbearing = 0; | ||
| 18257 | rbearing = width; | ||
| 18231 | } | 18258 | } |
| 18232 | 18259 | ||
| 18233 | rightmost = width; | 18260 | rightmost = width; |
| @@ -18247,6 +18274,8 @@ x_produce_glyphs (it) | |||
| 18247 | the left. */ | 18274 | the left. */ |
| 18248 | cmp->offsets[0] = 0; | 18275 | cmp->offsets[0] = 0; |
| 18249 | cmp->offsets[1] = boff; | 18276 | cmp->offsets[1] = boff; |
| 18277 | cmp->lbearing = lbearing; | ||
| 18278 | cmp->rbearing = rbearing; | ||
| 18250 | 18279 | ||
| 18251 | /* Set cmp->offsets for the remaining glyphs. */ | 18280 | /* Set cmp->offsets for the remaining glyphs. */ |
| 18252 | for (i = 1; i < cmp->glyph_len; i++) | 18281 | for (i = 1; i < cmp->glyph_len; i++) |
| @@ -18281,12 +18310,20 @@ x_produce_glyphs (it) | |||
| 18281 | width = pcm->width; | 18310 | width = pcm->width; |
| 18282 | ascent = pcm->ascent; | 18311 | ascent = pcm->ascent; |
| 18283 | descent = pcm->descent; | 18312 | descent = pcm->descent; |
| 18313 | lbearing = pcm->lbearing; | ||
| 18314 | if (lbearing > 0) | ||
| 18315 | lbearing = 0; | ||
| 18316 | rbearing = pcm->rbearing; | ||
| 18317 | if (rbearing < width) | ||
| 18318 | rbearing = width; | ||
| 18284 | } | 18319 | } |
| 18285 | else | 18320 | else |
| 18286 | { | 18321 | { |
| 18287 | width = FONT_WIDTH (font); | 18322 | width = FONT_WIDTH (font); |
| 18288 | ascent = 1; | 18323 | ascent = 1; |
| 18289 | descent = 0; | 18324 | descent = 0; |
| 18325 | lbearing = 0; | ||
| 18326 | rbearing = width; | ||
| 18290 | } | 18327 | } |
| 18291 | 18328 | ||
| 18292 | if (cmp->method != COMPOSITION_WITH_RULE_ALTCHARS) | 18329 | if (cmp->method != COMPOSITION_WITH_RULE_ALTCHARS) |
| @@ -18327,15 +18364,21 @@ x_produce_glyphs (it) | |||
| 18327 | 6---7---8 -- descent | 18364 | 6---7---8 -- descent |
| 18328 | */ | 18365 | */ |
| 18329 | int rule = COMPOSITION_RULE (cmp, i); | 18366 | int rule = COMPOSITION_RULE (cmp, i); |
| 18330 | int gref, nref, grefx, grefy, nrefx, nrefy; | 18367 | int gref, nref, grefx, grefy, nrefx, nrefy, xoff, yoff; |
| 18331 | 18368 | ||
| 18332 | COMPOSITION_DECODE_RULE (rule, gref, nref); | 18369 | COMPOSITION_DECODE_RULE (rule, gref, nref, xoff, yoff); |
| 18333 | grefx = gref % 3, nrefx = nref % 3; | 18370 | grefx = gref % 3, nrefx = nref % 3; |
| 18334 | grefy = gref / 3, nrefy = nref / 3; | 18371 | grefy = gref / 3, nrefy = nref / 3; |
| 18372 | if (xoff) | ||
| 18373 | xoff = font_height * (xoff - 128) / 256; | ||
| 18374 | if (yoff) | ||
| 18375 | yoff = font_height * (yoff - 128) / 256; | ||
| 18335 | 18376 | ||
| 18336 | left = (leftmost | 18377 | left = (leftmost |
| 18337 | + grefx * (rightmost - leftmost) / 2 | 18378 | + grefx * (rightmost - leftmost) / 2 |
| 18338 | - nrefx * width / 2); | 18379 | - nrefx * width / 2 |
| 18380 | + xoff); | ||
| 18381 | |||
| 18339 | btm = ((grefy == 0 ? highest | 18382 | btm = ((grefy == 0 ? highest |
| 18340 | : grefy == 1 ? 0 | 18383 | : grefy == 1 ? 0 |
| 18341 | : grefy == 2 ? lowest | 18384 | : grefy == 2 ? lowest |
| @@ -18343,23 +18386,32 @@ x_produce_glyphs (it) | |||
| 18343 | - (nrefy == 0 ? ascent + descent | 18386 | - (nrefy == 0 ? ascent + descent |
| 18344 | : nrefy == 1 ? descent - boff | 18387 | : nrefy == 1 ? descent - boff |
| 18345 | : nrefy == 2 ? 0 | 18388 | : nrefy == 2 ? 0 |
| 18346 | : (ascent + descent) / 2)); | 18389 | : (ascent + descent) / 2) |
| 18390 | + yoff); | ||
| 18347 | } | 18391 | } |
| 18348 | 18392 | ||
| 18349 | cmp->offsets[i * 2] = left; | 18393 | cmp->offsets[i * 2] = left; |
| 18350 | cmp->offsets[i * 2 + 1] = btm + descent; | 18394 | cmp->offsets[i * 2 + 1] = btm + descent; |
| 18351 | 18395 | ||
| 18352 | /* Update the bounding box of the overall glyphs. */ | 18396 | /* Update the bounding box of the overall glyphs. */ |
| 18353 | right = left + width; | 18397 | if (width > 0) |
| 18398 | { | ||
| 18399 | right = left + width; | ||
| 18400 | if (left < leftmost) | ||
| 18401 | leftmost = left; | ||
| 18402 | if (right > rightmost) | ||
| 18403 | rightmost = right; | ||
| 18404 | } | ||
| 18354 | top = btm + descent + ascent; | 18405 | top = btm + descent + ascent; |
| 18355 | if (left < leftmost) | ||
| 18356 | leftmost = left; | ||
| 18357 | if (right > rightmost) | ||
| 18358 | rightmost = right; | ||
| 18359 | if (top > highest) | 18406 | if (top > highest) |
| 18360 | highest = top; | 18407 | highest = top; |
| 18361 | if (btm < lowest) | 18408 | if (btm < lowest) |
| 18362 | lowest = btm; | 18409 | lowest = btm; |
| 18410 | |||
| 18411 | if (cmp->lbearing > left + lbearing) | ||
| 18412 | cmp->lbearing = left + lbearing; | ||
| 18413 | if (cmp->rbearing < left + rbearing) | ||
| 18414 | cmp->rbearing = left + rbearing; | ||
| 18363 | } | 18415 | } |
| 18364 | 18416 | ||
| 18365 | /* If there are glyphs whose x-offsets are negative, | 18417 | /* If there are glyphs whose x-offsets are negative, |
| @@ -18370,6 +18422,8 @@ x_produce_glyphs (it) | |||
| 18370 | for (i = 0; i < cmp->glyph_len; i++) | 18422 | for (i = 0; i < cmp->glyph_len; i++) |
| 18371 | cmp->offsets[i * 2] -= leftmost; | 18423 | cmp->offsets[i * 2] -= leftmost; |
| 18372 | rightmost -= leftmost; | 18424 | rightmost -= leftmost; |
| 18425 | cmp->lbearing -= leftmost; | ||
| 18426 | cmp->rbearing -= leftmost; | ||
| 18373 | } | 18427 | } |
| 18374 | 18428 | ||
| 18375 | cmp->pixel_width = rightmost; | 18429 | cmp->pixel_width = rightmost; |
| @@ -18381,6 +18435,11 @@ x_produce_glyphs (it) | |||
| 18381 | cmp->descent = font_descent; | 18435 | cmp->descent = font_descent; |
| 18382 | } | 18436 | } |
| 18383 | 18437 | ||
| 18438 | if (it->glyph_row | ||
| 18439 | && (cmp->lbearing < 0 | ||
| 18440 | || cmp->rbearing > cmp->pixel_width)) | ||
| 18441 | it->glyph_row->contains_overlapping_glyphs_p = 1; | ||
| 18442 | |||
| 18384 | it->pixel_width = cmp->pixel_width; | 18443 | it->pixel_width = cmp->pixel_width; |
| 18385 | it->ascent = it->phys_ascent = cmp->ascent; | 18444 | it->ascent = it->phys_ascent = cmp->ascent; |
| 18386 | it->descent = it->phys_descent = cmp->descent; | 18445 | it->descent = it->phys_descent = cmp->descent; |