all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#3975: 23.1; Line height too small with Monaco font on Mac OS X
@ 2009-07-30  9:22     ` Francis Devereux
       [not found]       ` <handler.3975.B.124894575813167.ack@emacsbugs.donarmstrong.com>
  2010-02-09  2:28       ` bug#3975: " Leo
  0 siblings, 2 replies; 10+ messages in thread
From: Francis Devereux @ 2009-07-30  9:22 UTC (permalink / raw
  To: bug-gnu-emacs

On Mac OS X the line height is too small when the Monaco font is used.
This causes, for example, the bottom of ( and ) characters to be
clipped.

Emacs 22.3 (Carbon port) works OK with this font.

Steps to reproduce:

1) Run nextstep/Emacs.app/Contents/MacOS/Emacs -q &

2) Switch to the *scratch* buffer

3) Evaluate (setq default-frame-alist (cons '(font . "-apple-monaco- 
medium-r-normal--10-100-72-72-m-100-mac-roman") default-frame-alist))

4) Type C-x 5 2 to open a new window

5) Type ()() to see the problem

I have uploaded a screenshot showing the problem to http://www.devrx.org/emacs/emacs-23-osx-font-problem.png

Francis


In GNU Emacs 23.1.1 (i386-apple-darwin9.7.0, NS apple-appkit-949.46)
  of 2009-07-30 on spaceman.local
Windowing system distributor `Apple', version 10.3.949
configured using `configure  '--with-ns''

Important settings:
   value of $LC_ALL: nil
   value of $LC_COLLATE: nil
   value of $LC_CTYPE: nil
   value of $LC_MESSAGES: nil
   value of $LC_MONETARY: nil
   value of $LC_NUMERIC: nil
   value of $LC_TIME: nil
   value of $LANG: en_GB.UTF-8
   value of $XMODIFIERS: nil
   locale-coding-system: utf-8-unix
   default-enable-multibyte-characters: t

Major mode: Lisp Interaction

Minor modes in effect:
   tooltip-mode: t
   mouse-wheel-mode: t
   menu-bar-mode: t
   file-name-shadow-mode: t
   global-font-lock-mode: t
   font-lock-mode: t
   global-auto-composition-mode: t
   auto-composition-mode: t
   auto-encryption-mode: t
   auto-compression-mode: t
   line-number-mode: t
   transient-mark-mode: t

Recent input:
C-x b * s c <tab> <return> C-y C-x C-e C-x 5 2 <left>
<right> <wheel-up> <switch-frame> <down-mouse-1> <mouse-movement>
<drag-mouse-1> <return> <return> ( s e t q SPC C-y
C-y <down-mouse-2> <mouse-2> ) <up> <up> C-a <right>
<right> <right> <right> <right> <right> <right> C-d
<down> C-a <right> C-d <down> C-d C-e C-x C-e <help-echo>
<down-mouse-1> <mouse-1> ' <down> C-a <right> ' <down>
<left> ' C-x C-e C-g C-e C-x C-e <help-echo> <down-mouse-1>
<mouse-1> <right> <backspace> <backspace> C-e <backspace>
<down> C-a <right> C-d C-d C-e <backspace> <down> C-a
<right> C-d C-d C-e <left> <backspace> <right> C-x
C-e M-x C-g <down-mouse-1> <mouse-1> C-x 5 2 <down-mouse-1>
<mouse-1> M-x r e p o r t - e m <tab> <return>

Recent messages:
((font . "-apple-monaco-medium-r-normal--10-100-72-72-m-100-mac- 
roman") (tool-bar-lines . 0) (menu-bar-lines . 1))
byte-code: Beginning of buffer
Mark set [4 times]
Entering debugger...
(ns-antialias-text nil)
Quit
Entering debugger...
meta
Quit
goto-history-element: Beginning of history; no preceding item







^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#3975: 23.1; [PATCH] Line height too small with Monaco font on Mac OS X
       [not found]       ` <handler.3975.B.124894575813167.ack@emacsbugs.donarmstrong.com>
@ 2009-07-30 22:57         ` Francis Devereux
  0 siblings, 0 replies; 10+ messages in thread
From: Francis Devereux @ 2009-07-30 22:57 UTC (permalink / raw
  To: 3975

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






^ permalink raw reply	[flat|nested] 10+ messages in thread

* Line height too small with Monaco font on Mac OS X
@ 2010-02-08 11:10 Francis Devereux
  2010-02-08 20:16 ` Leo
  2010-02-08 21:15 ` David Reitter
  0 siblings, 2 replies; 10+ messages in thread
From: Francis Devereux @ 2010-02-08 11:10 UTC (permalink / raw
  To: emacs-devel

Hi,

A few months ago I tried out Emacs 23.1 on Mac OS X, and found that  
the line height was too small when using the Monaco font (some  
characters are clipped at the bottom, including ()[]).  I downloaded  
and compiled Emacs 23.1.92 today and found that it still has the same  
problem.

Could someone have a look at the patch I added to http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3975 
  and apply it if it looks OK?

Thanks,

Francis




^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Line height too small with Monaco font on Mac OS X
  2010-02-08 11:10 Line height too small with Monaco font on Mac OS X Francis Devereux
@ 2010-02-08 20:16 ` Leo
  2010-02-08 23:43   ` Chong Yidong
  2010-02-08 23:43   ` Chong Yidong
  2010-02-08 21:15 ` David Reitter
  1 sibling, 2 replies; 10+ messages in thread
From: Leo @ 2010-02-08 20:16 UTC (permalink / raw
  To: emacs-devel

On 2010-02-08 11:10 +0000, Francis Devereux wrote:
> A few months ago I tried out Emacs 23.1 on Mac OS X, and found that
> the line height was too small when using the Monaco font (some
> characters are clipped at the bottom, including ()[]).  I downloaded
> and compiled Emacs 23.1.92 today and found that it still has the same
> problem.
>
> Could someone have a look at the patch I added to
> http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3975
>  and apply it if it looks OK?

No wonder I always feel a bit weird using monaco. I have moved to DejaVu
Sans Mono and it is looking better.

Patch is attached to bug #3975. Maybe someone can review it?

Thanks.

Leo





^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Line height too small with Monaco font on Mac OS X
  2010-02-08 11:10 Line height too small with Monaco font on Mac OS X Francis Devereux
  2010-02-08 20:16 ` Leo
@ 2010-02-08 21:15 ` David Reitter
  1 sibling, 0 replies; 10+ messages in thread
From: David Reitter @ 2010-02-08 21:15 UTC (permalink / raw
  To: Francis Devereux, Chong Yidong; +Cc: emacs-devel@gnu.org discussions


[-- Attachment #1.1: Type: text/plain, Size: 628 bytes --]

Francis,

On Feb 8, 2010, at 6:10 AM, Francis Devereux wrote:

> Could someone have a look at the patch I added to http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3975 and apply it if it looks OK?

This looks good to me.  It doesn't affect other font sizes (at least not Monaco 13).  Thanks for fixing this problem.

I've reformatted it a little for coding style - see attached.

Could someone with a bzr setup commit this by any chance?



2010-02-08  Francis Devereux <francis@devrx.org>

	* nsfont.m (nsfont_open): Round descender dimension 
	towards greater height as to not cause clipping
	(Bug #3975).



[-- Attachment #1.2: lineheight.patch --]
[-- Type: application/octet-stream, Size: 1383 bytes --]

diff --git a/src/nsfont.m b/src/nsfont.m
index d5107f3..6b258ce 100644
--- a/src/nsfont.m
+++ b/src/nsfont.m
@@ -844,8 +844,11 @@ nsfont_open (FRAME_PTR f, Lisp_Object font_entity, int pixel_size)
     /* 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);
@@ -878,10 +881,9 @@ nsfont_open (FRAME_PTR f, Lisp_Object font_entity, int pixel_size)
       font_info->cgfont = CGFontCreateWithPlatformFont ((void*)&atsFont);
     }
 #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 = ns_char_width(sfont, '|');
     font->space_width = lrint (ns_char_width (sfont, ' '));
     font->average_width = lrint (font_info->width);

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 203 bytes --]

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* bug#3975: Line height too small with Monaco font on Mac OS X
  2010-02-08 20:16 ` Leo
  2010-02-08 23:43   ` Chong Yidong
@ 2010-02-08 23:43   ` Chong Yidong
  2009-07-30  9:22     ` bug#3975: 23.1; " Francis Devereux
  1 sibling, 1 reply; 10+ messages in thread
From: Chong Yidong @ 2010-02-08 23:43 UTC (permalink / raw
  To: Leo; +Cc: francis, 3975, emacs-devel

Leo <sdl.web@gmail.com> writes:

> On 2010-02-08 11:10 +0000, Francis Devereux wrote:
>> A few months ago I tried out Emacs 23.1 on Mac OS X, and found that
>> the line height was too small when using the Monaco font (some
>> characters are clipped at the bottom, including ()[]).  I downloaded
>> and compiled Emacs 23.1.92 today and found that it still has the same
>> problem.
>>
>> Could someone have a look at the patch I added to
>> http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3975
>>  and apply it if it looks OK?
>
> No wonder I always feel a bit weird using monaco. I have moved to DejaVu
> Sans Mono and it is looking better.
>
> Patch is attached to bug #3975. Maybe someone can review it?

I've reviewed the patch, and it looks ok.  I've checked it in, could you
test it?






^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Line height too small with Monaco font on Mac OS X
  2010-02-08 20:16 ` Leo
@ 2010-02-08 23:43   ` Chong Yidong
  2010-02-11 13:45     ` Francis Devereux
  2010-02-11 13:45     ` bug#3975: " Francis Devereux
  2010-02-08 23:43   ` Chong Yidong
  1 sibling, 2 replies; 10+ messages in thread
From: Chong Yidong @ 2010-02-08 23:43 UTC (permalink / raw
  To: Leo; +Cc: francis, 3975, emacs-devel

Leo <sdl.web@gmail.com> writes:

> On 2010-02-08 11:10 +0000, Francis Devereux wrote:
>> A few months ago I tried out Emacs 23.1 on Mac OS X, and found that
>> the line height was too small when using the Monaco font (some
>> characters are clipped at the bottom, including ()[]).  I downloaded
>> and compiled Emacs 23.1.92 today and found that it still has the same
>> problem.
>>
>> Could someone have a look at the patch I added to
>> http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3975
>>  and apply it if it looks OK?
>
> No wonder I always feel a bit weird using monaco. I have moved to DejaVu
> Sans Mono and it is looking better.
>
> Patch is attached to bug #3975. Maybe someone can review it?

I've reviewed the patch, and it looks ok.  I've checked it in, could you
test it?




^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#3975: Line height too small with Monaco font on Mac OS X
  2009-07-30  9:22     ` bug#3975: 23.1; " Francis Devereux
       [not found]       ` <handler.3975.B.124894575813167.ack@emacsbugs.donarmstrong.com>
@ 2010-02-09  2:28       ` Leo
  1 sibling, 0 replies; 10+ messages in thread
From: Leo @ 2010-02-09  2:28 UTC (permalink / raw
  To: bug-gnu-emacs

On 2010-02-08 23:43 +0000, Chong Yidong wrote:
>> No wonder I always feel a bit weird using monaco. I have moved to
>> DejaVu Sans Mono and it is looking better.
>>
>> Patch is attached to bug #3975. Maybe someone can review it?
>
> I've reviewed the patch, and it looks ok. I've checked it in, could
> you test it?

Unfortunately it is a bit awkward for me to test it now as I no longer
use the ns port and the font but maybe someone else can test it.

Leo








^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#3975: Line height too small with Monaco font on Mac OS X
  2010-02-08 23:43   ` Chong Yidong
  2010-02-11 13:45     ` Francis Devereux
@ 2010-02-11 13:45     ` Francis Devereux
  1 sibling, 0 replies; 10+ messages in thread
From: Francis Devereux @ 2010-02-11 13:45 UTC (permalink / raw
  To: Chong Yidong; +Cc: Leo, 3975, emacs-devel

On 8 Feb 2010, at 23:43, Chong Yidong wrote:

> Leo <sdl.web@gmail.com> writes:
>
>> On 2010-02-08 11:10 +0000, Francis Devereux wrote:
>>> A few months ago I tried out Emacs 23.1 on Mac OS X, and found that
>>> the line height was too small when using the Monaco font (some
>>> characters are clipped at the bottom, including ()[]).  I downloaded
>>> and compiled Emacs 23.1.92 today and found that it still has the  
>>> same
>>> problem.
>>>
>>> Could someone have a look at the patch I added to
>>> http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3975
>>> and apply it if it looks OK?
>>
>> No wonder I always feel a bit weird using monaco. I have moved to  
>> DejaVu
>> Sans Mono and it is looking better.
>>
>> Patch is attached to bug #3975. Maybe someone can review it?
>
> I've reviewed the patch, and it looks ok.  I've checked it in, could  
> you
> test it?

Thanks, I've tested bzr trunk r99485 and the bug is fixed there.

Francis







^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Line height too small with Monaco font on Mac OS X
  2010-02-08 23:43   ` Chong Yidong
@ 2010-02-11 13:45     ` Francis Devereux
  2010-02-11 13:45     ` bug#3975: " Francis Devereux
  1 sibling, 0 replies; 10+ messages in thread
From: Francis Devereux @ 2010-02-11 13:45 UTC (permalink / raw
  To: Chong Yidong; +Cc: Leo, 3975, emacs-devel

On 8 Feb 2010, at 23:43, Chong Yidong wrote:

> Leo <sdl.web@gmail.com> writes:
>
>> On 2010-02-08 11:10 +0000, Francis Devereux wrote:
>>> A few months ago I tried out Emacs 23.1 on Mac OS X, and found that
>>> the line height was too small when using the Monaco font (some
>>> characters are clipped at the bottom, including ()[]).  I downloaded
>>> and compiled Emacs 23.1.92 today and found that it still has the  
>>> same
>>> problem.
>>>
>>> Could someone have a look at the patch I added to
>>> http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3975
>>> and apply it if it looks OK?
>>
>> No wonder I always feel a bit weird using monaco. I have moved to  
>> DejaVu
>> Sans Mono and it is looking better.
>>
>> Patch is attached to bug #3975. Maybe someone can review it?
>
> I've reviewed the patch, and it looks ok.  I've checked it in, could  
> you
> test it?

Thanks, I've tested bzr trunk r99485 and the bug is fixed there.

Francis





^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2010-02-11 13:45 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-02-08 11:10 Line height too small with Monaco font on Mac OS X Francis Devereux
2010-02-08 20:16 ` Leo
2010-02-08 23:43   ` Chong Yidong
2010-02-11 13:45     ` Francis Devereux
2010-02-11 13:45     ` bug#3975: " Francis Devereux
2010-02-08 23:43   ` 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         ` bug#3975: 23.1; [PATCH] " Francis Devereux
2010-02-09  2:28       ` bug#3975: " Leo
2010-02-08 21:15 ` David Reitter

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.