From 643470ff797407b256eea380e0f41d3749400927 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Sat, 30 May 2015 19:25:53 +0300 Subject: [PATCH] Fix display of composite characters with large fonts * src/xdisp.c (x_produce_glyphs): Call normal_char_ascent_descent for reasonable values of font ascent and descent. (get_font_ascent_descent): New function. * src/composite.c (composition_gstring_width): Call get_font_ascent_descent for reasonable values of font ascent and descent. * dispextern.h: Add prototype for get_font_ascent_descent. --- src/composite.c | 6 ++++-- src/dispextern.h | 2 ++ src/xdisp.c | 18 +++++++++++++++--- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/src/composite.c b/src/composite.c index 577b97920f4..e942eef3006 100644 --- a/src/composite.c +++ b/src/composite.c @@ -732,9 +732,11 @@ composition_gstring_width (Lisp_Object gstring, ptrdiff_t from, ptrdiff_t to, if (FONT_OBJECT_P (font_object)) { struct font *font = XFONT_OBJECT (font_object); + int font_ascent, font_descent; - metrics->ascent = font->ascent; - metrics->descent = font->descent; + get_font_ascent_descent (font, &font_ascent, &font_descent); + metrics->ascent = font_ascent; + metrics->descent = font_descent; } else { diff --git a/src/dispextern.h b/src/dispextern.h index 1537d44330d..5202142313a 100644 --- a/src/dispextern.h +++ b/src/dispextern.h @@ -3246,6 +3246,8 @@ extern ptrdiff_t compute_display_string_end (ptrdiff_t, extern void produce_stretch_glyph (struct it *); extern int merge_glyphless_glyph_face (struct it *); +extern void get_font_ascent_descent (struct font *, int *, int *); + #ifdef HAVE_WINDOW_SYSTEM #ifdef GLYPH_DEBUG diff --git a/src/xdisp.c b/src/xdisp.c index 50d7376b28a..53303272e60 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -24079,6 +24079,17 @@ calc_pixel_width_or_height (double *res, struct it *it, Lisp_Object prop, return false; } +void +get_font_ascent_descent (struct font *font, int *ascent, int *descent) +{ +#ifdef HAVE_WINDOW_SYSTEM + normal_char_ascent_descent (font, -1, ascent, descent); +#else + *ascent = 1; + *descent = 0; +#endif +} + /*********************************************************************** Glyph Display @@ -26818,9 +26829,10 @@ x_produce_glyphs (struct it *it) boff = font->baseline_offset; if (font->vertical_centering) boff = VCENTER_BASELINE_OFFSET (font, it->f) - boff; - font_ascent = FONT_BASE (font) + boff; - font_descent = FONT_DESCENT (font) - boff; - font_height = FONT_HEIGHT (font); + normal_char_ascent_descent (font, -1, &font_ascent, &font_descent); + font_ascent += boff; + font_descent -= boff; + font_height = font_ascent + font_descent; cmp->font = font; -- 2.39.2