aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEli Zaretskii2015-05-29 17:09:45 +0300
committerEli Zaretskii2015-05-29 17:09:45 +0300
commit5f734fa045c7d10c46c3a25ddd6e5f3d6b45182a (patch)
tree43cfbd63498ba646e8df0aa15236278c853fef0b /src
parentc5228486590c1f31c56f9ea67667617966818cba (diff)
downloademacs-5f734fa045c7d10c46c3a25ddd6e5f3d6b45182a.tar.gz
emacs-5f734fa045c7d10c46c3a25ddd6e5f3d6b45182a.zip
Fix line dimensions from line-height property
* src/xdisp.c (normal_char_ascent_descent): New function, extracted from produce_glyphless_glyph. (calc_line_height_property, produce_glyphless_glyph): Use it to compute reasonable estimates of ascent and descent for large fonts.
Diffstat (limited to 'src')
-rw-r--r--src/xdisp.c51
1 files changed, 29 insertions, 22 deletions
diff --git a/src/xdisp.c b/src/xdisp.c
index f3a3a7f7b02..29b97abcb95 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -24597,6 +24597,33 @@ normal_char_height (struct font *font)
24597 return default_height; 24597 return default_height;
24598} 24598}
24599 24599
24600/* A subroutine that computes "normal" values of ascent and descent
24601 for fonts that claim preposterously large values, but whose glyphs
24602 actually have reasonable dimensions. */
24603static void
24604normal_char_ascent_descent (struct font *font, int *ascent, int *descent)
24605{
24606 *ascent = FONT_BASE (font);
24607 *descent = FONT_DESCENT (font);
24608
24609 if (FONT_TOO_HIGH (font))
24610 {
24611 XChar2b char2b;
24612
24613 /* Get metrics of a reasonably sized ASCII character. */
24614 if (get_char_glyph_code ('{', font, &char2b))
24615 {
24616 struct font_metrics *pcm = get_per_char_metric (font, &char2b);
24617
24618 if (!(pcm->width == 0 && pcm->rbearing == 0 && pcm->lbearing == 0))
24619 {
24620 *ascent = pcm->ascent;
24621 *descent = pcm->descent;
24622 }
24623 }
24624 }
24625}
24626
24600/* EXPORT for RIF: 24627/* EXPORT for RIF:
24601 Set *LEFT and *RIGHT to the left and right overhang of GLYPH on 24628 Set *LEFT and *RIGHT to the left and right overhang of GLYPH on
24602 frame F. Overhangs of glyphs other than type CHAR_GLYPH are 24629 frame F. Overhangs of glyphs other than type CHAR_GLYPH are
@@ -26132,8 +26159,7 @@ calc_line_height_property (struct it *it, Lisp_Object val, struct font *font,
26132 boff = VCENTER_BASELINE_OFFSET (font, it->f) - boff; 26159 boff = VCENTER_BASELINE_OFFSET (font, it->f) - boff;
26133 } 26160 }
26134 26161
26135 ascent = FONT_BASE (font) + boff; 26162 normal_char_ascent_descent (font, &ascent, &descent);
26136 descent = FONT_DESCENT (font) - boff;
26137 26163
26138 if (override) 26164 if (override)
26139 { 26165 {
@@ -26259,26 +26285,7 @@ produce_glyphless_glyph (struct it *it, bool for_no_font, Lisp_Object acronym)
26259 ASCII face. */ 26285 ASCII face. */
26260 face = FACE_FROM_ID (it->f, it->face_id)->ascii_face; 26286 face = FACE_FROM_ID (it->f, it->face_id)->ascii_face;
26261 font = face->font ? face->font : FRAME_FONT (it->f); 26287 font = face->font ? face->font : FRAME_FONT (it->f);
26262 it->ascent = FONT_BASE (font); 26288 normal_char_ascent_descent (font, &it->ascent, &it->descent);
26263 it->descent = FONT_DESCENT (font);
26264 /* Attempt to fix box height for fonts that claim preposterously
26265 large height. */
26266 if (FONT_TOO_HIGH (font))
26267 {
26268 XChar2b char2b;
26269
26270 /* Get metrics of a reasonably sized ASCII character. */
26271 if (get_char_glyph_code ('{', font, &char2b))
26272 {
26273 struct font_metrics *pcm = get_per_char_metric (font, &char2b);
26274
26275 if (!(pcm->width == 0 && pcm->rbearing == 0 && pcm->lbearing == 0))
26276 {
26277 it->ascent = pcm->ascent;
26278 it->descent = pcm->descent;
26279 }
26280 }
26281 }
26282 it->ascent += font->baseline_offset; 26289 it->ascent += font->baseline_offset;
26283 it->descent -= font->baseline_offset; 26290 it->descent -= font->baseline_offset;
26284 base_height = it->ascent + it->descent; 26291 base_height = it->ascent + it->descent;