diff options
| author | Kenichi Handa | 2008-02-25 01:43:02 +0000 |
|---|---|---|
| committer | Kenichi Handa | 2008-02-25 01:43:02 +0000 |
| commit | b876ea9155f1f244515e1af4287b6f899b754db0 (patch) | |
| tree | 370770431f6d811f5a61ef34d51d45cfdb89a10d /src | |
| parent | a1fe5dfaf737461619d5ac5fcc796048b9ada97e (diff) | |
| download | emacs-b876ea9155f1f244515e1af4287b6f899b754db0.tar.gz emacs-b876ea9155f1f244515e1af4287b6f899b754db0.zip | |
If the font driver doesn't have `shape' function, return Qnil.
Diffstat (limited to 'src')
| -rw-r--r-- | src/font.c | 46 |
1 files changed, 6 insertions, 40 deletions
diff --git a/src/font.c b/src/font.c index c63a15889fc..57609a8dab4 100644 --- a/src/font.c +++ b/src/font.c | |||
| @@ -3625,6 +3625,12 @@ FONT-OBJECT. */) | |||
| 3625 | Lisp_Object gstring, n; | 3625 | Lisp_Object gstring, n; |
| 3626 | int len, i, j; | 3626 | int len, i, j; |
| 3627 | 3627 | ||
| 3628 | if (! FONT_OBJECT_P (font_object)) | ||
| 3629 | return Qnil; | ||
| 3630 | CHECK_FONT_GET_OBJECT (font_object, font); | ||
| 3631 | if (! font->driver->shape) | ||
| 3632 | return Qnil; | ||
| 3633 | |||
| 3628 | if (NILP (string)) | 3634 | if (NILP (string)) |
| 3629 | { | 3635 | { |
| 3630 | validate_region (&from, &to); | 3636 | validate_region (&from, &to); |
| @@ -3641,49 +3647,9 @@ FONT-OBJECT. */) | |||
| 3641 | args_out_of_range_3 (string, from, to); | 3647 | args_out_of_range_3 (string, from, to); |
| 3642 | } | 3648 | } |
| 3643 | 3649 | ||
| 3644 | if (! FONT_OBJECT_P (font_object)) | ||
| 3645 | return to; | ||
| 3646 | |||
| 3647 | CHECK_FONT_GET_OBJECT (font_object, font); | ||
| 3648 | len = end - start; | 3650 | len = end - start; |
| 3649 | gstring = Ffont_make_gstring (font_object, make_number (len)); | 3651 | gstring = Ffont_make_gstring (font_object, make_number (len)); |
| 3650 | Ffont_fill_gstring (gstring, font_object, from, to, string); | 3652 | Ffont_fill_gstring (gstring, font_object, from, to, string); |
| 3651 | if (! font->driver->shape) | ||
| 3652 | { | ||
| 3653 | /* Make zero-width glyphs to have one pixel width to make the | ||
| 3654 | display routine not lose the cursor. */ | ||
| 3655 | for (i = 0; i < len; i++) | ||
| 3656 | { | ||
| 3657 | Lisp_Object g = LGSTRING_GLYPH (gstring, i); | ||
| 3658 | unsigned code; | ||
| 3659 | struct font_metrics metrics; | ||
| 3660 | |||
| 3661 | if (NILP (g)) | ||
| 3662 | break; | ||
| 3663 | code = LGLYPH_CODE (g); | ||
| 3664 | if (font->driver->text_extents (font, &code, 1, &metrics) == 0) | ||
| 3665 | { | ||
| 3666 | Lisp_Object gstr = Ffont_make_gstring (font_object, | ||
| 3667 | make_number (1)); | ||
| 3668 | LGSTRING_SET_WIDTH (gstr, 1); | ||
| 3669 | LGSTRING_SET_LBEARING (gstr, metrics.lbearing); | ||
| 3670 | LGSTRING_SET_RBEARING (gstr, metrics.rbearing + 1); | ||
| 3671 | LGSTRING_SET_ASCENT (gstr, metrics.ascent); | ||
| 3672 | LGSTRING_SET_DESCENT (gstr, metrics.descent); | ||
| 3673 | LGLYPH_SET_FROM (g, 0); | ||
| 3674 | LGLYPH_SET_TO (g, 1); | ||
| 3675 | LGSTRING_SET_GLYPH (gstr, 0, g); | ||
| 3676 | from = make_number (start + i); | ||
| 3677 | to = make_number (start + i + 1); | ||
| 3678 | if (NILP (string)) | ||
| 3679 | Fcompose_region_internal (from, to, gstr, Qnil); | ||
| 3680 | else | ||
| 3681 | Fcompose_string_internal (string, from, to, gstr, Qnil); | ||
| 3682 | } | ||
| 3683 | } | ||
| 3684 | return make_number (end); | ||
| 3685 | } | ||
| 3686 | |||
| 3687 | 3653 | ||
| 3688 | /* Try at most three times with larger gstring each time. */ | 3654 | /* Try at most three times with larger gstring each time. */ |
| 3689 | for (i = 0; i < 3; i++) | 3655 | for (i = 0; i < 3; i++) |