diff options
| author | Kenichi Handa | 2007-12-21 01:38:14 +0000 |
|---|---|---|
| committer | Kenichi Handa | 2007-12-21 01:38:14 +0000 |
| commit | b293711968da4afd8b52cdb3e140f0df74cd4c11 (patch) | |
| tree | 23d34a110acd59635dd6200181134cae310511cd /src | |
| parent | 28e2436abf38747725cf50c7b7967c66dfa5f883 (diff) | |
| download | emacs-b293711968da4afd8b52cdb3e140f0df74cd4c11.tar.gz emacs-b293711968da4afd8b52cdb3e140f0df74cd4c11.zip | |
(Ffont_shape_text): Avoid unnecessary composition.
Diffstat (limited to 'src')
| -rw-r--r-- | src/font.c | 40 |
1 files changed, 26 insertions, 14 deletions
diff --git a/src/font.c b/src/font.c index 51f9ffa0a24..10dce4764a2 100644 --- a/src/font.c +++ b/src/font.c | |||
| @@ -3581,13 +3581,18 @@ The value is the end position of the shaped text. */) | |||
| 3581 | EMACS_INT this_from = LGLYPH_FROM (g); | 3581 | EMACS_INT this_from = LGLYPH_FROM (g); |
| 3582 | EMACS_INT this_to = LGLYPH_TO (g) + 1; | 3582 | EMACS_INT this_to = LGLYPH_TO (g) + 1; |
| 3583 | int j, k; | 3583 | int j, k; |
| 3584 | int need_composition = 0; | ||
| 3584 | 3585 | ||
| 3585 | metrics.lbearing = LGLYPH_LBEARING (g); | 3586 | metrics.lbearing = LGLYPH_LBEARING (g); |
| 3586 | metrics.rbearing = LGLYPH_RBEARING (g); | 3587 | metrics.rbearing = LGLYPH_RBEARING (g); |
| 3587 | metrics.ascent = LGLYPH_ASCENT (g); | 3588 | metrics.ascent = LGLYPH_ASCENT (g); |
| 3588 | metrics.descent = LGLYPH_DESCENT (g); | 3589 | metrics.descent = LGLYPH_DESCENT (g); |
| 3589 | if (NILP (LGLYPH_ADJUSTMENT (g))) | 3590 | if (NILP (LGLYPH_ADJUSTMENT (g))) |
| 3590 | metrics.width = LGLYPH_WIDTH (g); | 3591 | { |
| 3592 | metrics.width = LGLYPH_WIDTH (g); | ||
| 3593 | if (XINT (LGLYPH_CHAR (g)) == 0 || metrics.width == 0) | ||
| 3594 | need_composition = 1; | ||
| 3595 | } | ||
| 3591 | else | 3596 | else |
| 3592 | { | 3597 | { |
| 3593 | metrics.width = LGLYPH_WADJUST (g); | 3598 | metrics.width = LGLYPH_WADJUST (g); |
| @@ -3595,6 +3600,7 @@ The value is the end position of the shaped text. */) | |||
| 3595 | metrics.rbearing += LGLYPH_XOFF (g); | 3600 | metrics.rbearing += LGLYPH_XOFF (g); |
| 3596 | metrics.ascent -= LGLYPH_YOFF (g); | 3601 | metrics.ascent -= LGLYPH_YOFF (g); |
| 3597 | metrics.descent += LGLYPH_YOFF (g); | 3602 | metrics.descent += LGLYPH_YOFF (g); |
| 3603 | need_composition = 1; | ||
| 3598 | } | 3604 | } |
| 3599 | for (j = i + 1; j < XINT (n); j++) | 3605 | for (j = i + 1; j < XINT (n); j++) |
| 3600 | { | 3606 | { |
| @@ -3603,6 +3609,7 @@ The value is the end position of the shaped text. */) | |||
| 3603 | g = LGSTRING_GLYPH (gstring, j); | 3609 | g = LGSTRING_GLYPH (gstring, j); |
| 3604 | if (this_from != LGLYPH_FROM (g)) | 3610 | if (this_from != LGLYPH_FROM (g)) |
| 3605 | break; | 3611 | break; |
| 3612 | need_composition = 1; | ||
| 3606 | x = metrics.width + LGLYPH_LBEARING (g) + LGLYPH_XOFF (g); | 3613 | x = metrics.width + LGLYPH_LBEARING (g) + LGLYPH_XOFF (g); |
| 3607 | if (metrics.lbearing > x) | 3614 | if (metrics.lbearing > x) |
| 3608 | metrics.lbearing = x; | 3615 | metrics.lbearing = x; |
| @@ -3621,20 +3628,25 @@ The value is the end position of the shaped text. */) | |||
| 3621 | metrics.width += LGLYPH_WADJUST (g); | 3628 | metrics.width += LGLYPH_WADJUST (g); |
| 3622 | } | 3629 | } |
| 3623 | 3630 | ||
| 3624 | gstr = Ffont_make_gstring (font_object, make_number (j - i)); | 3631 | if (need_composition) |
| 3625 | LGSTRING_SET_WIDTH (gstr, metrics.width); | 3632 | { |
| 3626 | LGSTRING_SET_LBEARING (gstr, metrics.lbearing); | 3633 | gstr = Ffont_make_gstring (font_object, make_number (j - i)); |
| 3627 | LGSTRING_SET_RBEARING (gstr, metrics.rbearing); | 3634 | LGSTRING_SET_WIDTH (gstr, metrics.width); |
| 3628 | LGSTRING_SET_ASCENT (gstr, metrics.ascent); | 3635 | LGSTRING_SET_LBEARING (gstr, metrics.lbearing); |
| 3629 | LGSTRING_SET_DESCENT (gstr, metrics.descent); | 3636 | LGSTRING_SET_RBEARING (gstr, metrics.rbearing); |
| 3630 | for (k = i; i < j; i++) | 3637 | LGSTRING_SET_ASCENT (gstr, metrics.ascent); |
| 3631 | LGSTRING_SET_GLYPH (gstr, i - k, LGSTRING_GLYPH (gstring, i)); | 3638 | LGSTRING_SET_DESCENT (gstr, metrics.descent); |
| 3632 | from = make_number (start + this_from); | 3639 | for (k = i; i < j; i++) |
| 3633 | to = make_number (start + this_to); | 3640 | LGSTRING_SET_GLYPH (gstr, i - k, LGSTRING_GLYPH (gstring, i)); |
| 3634 | if (NILP (string)) | 3641 | from = make_number (start + this_from); |
| 3635 | Fcompose_region_internal (from, to, gstr, Qnil); | 3642 | to = make_number (start + this_to); |
| 3643 | if (NILP (string)) | ||
| 3644 | Fcompose_region_internal (from, to, gstr, Qnil); | ||
| 3645 | else | ||
| 3646 | Fcompose_string_internal (string, from, to, gstr, Qnil); | ||
| 3647 | } | ||
| 3636 | else | 3648 | else |
| 3637 | Fcompose_string_internal (string, from, to, gstr, Qnil); | 3649 | i = j; |
| 3638 | } | 3650 | } |
| 3639 | 3651 | ||
| 3640 | return to; | 3652 | return to; |