summaryrefslogtreecommitdiff
path: root/src/xdisp.c
diff options
context:
space:
mode:
authorEli Zaretskii <eliz@gnu.org>2015-05-28 20:23:41 +0300
committerEli Zaretskii <eliz@gnu.org>2015-05-28 20:23:41 +0300
commitc76605faa1f597e67df1e5c6cfae5230ff3a6a76 (patch)
tree8d5100ba36931d2e06b9e61b34028d9620cdbcd0 /src/xdisp.c
parent1d87cb3cfa08086be96f78ab09d99f3e7ba8ca60 (diff)
Fix display of glyphless characters with problematic fonts
* src/w32term.c (x_draw_glyph_string_background): Force redraw of glyph string background also when the font in use claims preposterously large global height value. Helps to remove artifacts left from previous displays when glyphless characters are displayed as hex code in a box. * src/xterm.c (x_draw_glyph_string_background): Force redraw of glyph string background also when the font in use claims preposterously large global height value. Helps to remove artifacts left from previous displays when glyphless characters are displayed as hex code in a box. * src/w32font.c (w32font_draw): Fix background drawing for glyphless characters that display as acronyms or hex codes in a box. * src/xftfont.c (xftfont_draw): Fix background drawing for glyphless characters that display as acronyms or hex codes in a box. * src/xdisp.c (produce_glyphless_glyph): Compute reasonable values for it->ascent and it->descent when the font claims preposterously large global values. (FONT_TOO_HIGH): Move from here... * src/dispextern.h (FONT_TOO_HIGH): ...to here.
Diffstat (limited to 'src/xdisp.c')
-rw-r--r--src/xdisp.c30
1 files changed, 22 insertions, 8 deletions
diff --git a/src/xdisp.c b/src/xdisp.c
index a1b7cf1438..ed430a424a 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -25296,12 +25296,6 @@ draw_glyphs (struct window *w, int x, struct glyph_row *row,
} \
}
-/* A heuristic test for fonts that claim they need a preposterously
- large vertical space. The heuristics is in the factor of 3. We
- ignore the ascent and descent values reported by such fonts, and
- instead go by the values reported for individual glyphs. */
-#define FONT_TOO_HIGH(ft) ((ft)->ascent + (ft)->descent > 3*(ft)->pixel_size)
-
/* Store one glyph for IT->char_to_display in IT->glyph_row.
Called from x_produce_glyphs when IT->glyph_row is non-null. */
@@ -26230,8 +26224,28 @@ produce_glyphless_glyph (struct it *it, bool for_no_font, Lisp_Object acronym)
ASCII face. */
face = FACE_FROM_ID (it->f, it->face_id)->ascii_face;
font = face->font ? face->font : FRAME_FONT (it->f);
- it->ascent = FONT_BASE (font) + font->baseline_offset;
- it->descent = FONT_DESCENT (font) - font->baseline_offset;
+ it->ascent = FONT_BASE (font);
+ it->descent = FONT_DESCENT (font);
+ /* Attempt to fix box height for fonts that claim preposterously
+ large height. */
+ if (FONT_TOO_HIGH (font))
+ {
+ XChar2b char2b;
+
+ /* Get metrics of a reasonably sized ASCII character. */
+ if (get_char_glyph_code ('{', font, &char2b))
+ {
+ struct font_metrics *pcm = get_per_char_metric (font, &char2b);
+
+ if (!(pcm->width == 0 && pcm->rbearing == 0 && pcm->lbearing == 0))
+ {
+ it->ascent = pcm->ascent;
+ it->descent = pcm->descent;
+ }
+ }
+ }
+ it->ascent += font->baseline_offset;
+ it->descent -= font->baseline_offset;
base_height = it->ascent + it->descent;
base_width = font->average_width;