emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] scratch/large-fonts 5f734fa 2/4: Fix line dimensions from


From: Eli Zaretskii
Subject: [Emacs-diffs] scratch/large-fonts 5f734fa 2/4: Fix line dimensions from line-height property
Date: Sat, 30 May 2015 09:34:12 +0000

branch: scratch/large-fonts
commit 5f734fa045c7d10c46c3a25ddd6e5f3d6b45182a
Author: Eli Zaretskii <address@hidden>
Commit: Eli Zaretskii <address@hidden>

    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.
---
 src/xdisp.c |   51 +++++++++++++++++++++++++++++----------------------
 1 files changed, 29 insertions(+), 22 deletions(-)

diff --git a/src/xdisp.c b/src/xdisp.c
index f3a3a7f..29b97ab 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -24597,6 +24597,33 @@ normal_char_height (struct font *font)
   return default_height;
 }
 
+/* A subroutine that computes "normal" values of ascent and descent
+   for fonts that claim preposterously large values, but whose glyphs
+   actually have reasonable dimensions.  */
+static void
+normal_char_ascent_descent (struct font *font, int *ascent, int *descent)
+{
+  *ascent = FONT_BASE (font);
+  *descent = FONT_DESCENT (font);
+
+  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))
+           {
+             *ascent = pcm->ascent;
+             *descent = pcm->descent;
+           }
+       }
+    }
+}
+
 /* EXPORT for RIF:
    Set *LEFT and *RIGHT to the left and right overhang of GLYPH on
    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,
        boff = VCENTER_BASELINE_OFFSET (font, it->f) - boff;
     }
 
-  ascent = FONT_BASE (font) + boff;
-  descent = FONT_DESCENT (font) - boff;
+  normal_char_ascent_descent (font, &ascent, &descent);
 
   if (override)
     {
@@ -26259,26 +26285,7 @@ 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);
-  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;
-           }
-       }
-    }
+  normal_char_ascent_descent (font, &it->ascent, &it->descent);
   it->ascent += font->baseline_offset;
   it->descent -= font->baseline_offset;
   base_height = it->ascent + it->descent;



reply via email to

[Prev in Thread] Current Thread [Next in Thread]