GNU bug report logs - #3975
23.1; Line height too small with Monaco font on Mac OS X

Previous Next

Packages: emacs, ns;

Reported by: Francis Devereux <francis <at> devrx.org>

Date: Thu, 30 Jul 2009 09:30:06 UTC

Severity: normal

Tags: moreinfo

Merged with 2836, 3961, 3986

Done: Chong Yidong <cyd <at> stupidchicken.com>

Bug is archived. No further changes may be made.

Full log


Message #10 received at 3975 <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Francis Devereux <francis <at> devrx.org>
To: 3975 <at> debbugs.gnu.org
Subject: Re: bug#3975: 23.1; [PATCH] Line height too small with Monaco font on Mac OS X
Date: Thu, 30 Jul 2009 23:57:49 +0100
I have done some investigating into this bug and found a fix.  The  
problem was being caused by [sfont descender] returning -2.5, which  
was being rounded to -2 by the lrint on line 807 of nsfont.c:
      -lrint (hshrink* [sfont descender] - expand*hd/2);

The following patch fixes the problem:
--- src/nsfont.m~	2009-07-30 00:39:40.000000000 +0100
+++ src/nsfont.m	2009-07-30 23:41:56.000000000 +0100
@@ -803,8 +803,11 @@
     /* max bounds */
     font_info->max_bounds.ascent =
       lrint (hshrink * [sfont ascender] + expand * hd/2);
+    /* [sfont descender] is usually negative, so we use floor to round
+       towards the integer with the greater magnitude so that we  
don't clip
+       any descenders. */
     font_info->max_bounds.descent =
-      -lrint (hshrink* [sfont descender] - expand*hd/2);
+      -lrint (floor(hshrink* [sfont descender] - expand*hd/2));
     font_info->height =
       font_info->max_bounds.ascent + font_info->max_bounds.descent;
     font_info->max_bounds.width = lrint (font_info->width);
@@ -839,8 +842,8 @@
 #endif

     /* set up metrics portion of font struct */
-    font->ascent = [sfont ascender];
-    font->descent = -[sfont descender];
+    font->ascent = lrint([sfont ascender]);
+    font->descent = -lrint(floor([sfont descender]));
     font->min_width = [sfont widthOfString: @"|"]; /* FIXME */
     font->space_width = lrint (ns_char_width (sfont, ' '));
     font->average_width = lrint (font_info->width);

The second hunk does not actually seem to be necessary, but I added it  
for consistency.

I think that this patch may also fix bug 3961 (Incorrect font height  
on Mac OS X).

Francis




This bug report was last modified 15 years and 103 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.