unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Francis Devereux <francis@devrx.org>
To: 3975@emacsbugs.donarmstrong.com
Subject: 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	[thread overview]
Message-ID: <F8986DD6-E3EE-4F26-A5FB-9221827901BA@devrx.org> (raw)
In-Reply-To: <handler.3975.B.124894575813167.ack@emacsbugs.donarmstrong.com>

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






  parent reply	other threads:[~2009-07-30 22:57 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <256A1330-5C0B-4F54-926E-83C95923067D@devrx.org>
     [not found] ` <xbaiaavjpjob.fsf@cam.ac.uk>
2010-02-08 23:43   ` bug#3975: Line height too small with Monaco font on Mac OS X Chong Yidong
2009-07-30  9:22     ` bug#3975: 23.1; " Francis Devereux
     [not found]       ` <handler.3975.B.124894575813167.ack@emacsbugs.donarmstrong.com>
2009-07-30 22:57         ` Francis Devereux [this message]
2010-02-09  2:28       ` bug#3975: " Leo
     [not found]   ` <874olrz41x.fsf@stupidchicken.com>
2010-02-11 13:45     ` Francis Devereux

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=F8986DD6-E3EE-4F26-A5FB-9221827901BA@devrx.org \
    --to=francis@devrx.org \
    --cc=3975@emacsbugs.donarmstrong.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).