all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Font height issue
@ 2016-02-25 19:34 Tassilo Horn
  2016-02-25 19:49 ` Marcin Borkowski
  2016-02-25 20:04 ` Eli Zaretskii
  0 siblings, 2 replies; 4+ messages in thread
From: Tassilo Horn @ 2016-02-25 19:34 UTC (permalink / raw
  To: emacs-devel

Hi all,

I have the problem that the font I want to use in Emacs (PragmataPro in
size 10, sizes 9 or 11 seem to be not affected) seems to have slightly
different heights in the regular and the bold version, or at least Emacs
thinks so.  As a result, when modes change text to/from regular to bold
or vice versa dynamically (e.g., show-paren-mode with a bold
show-paren-match face), the height of the line changes which is
extremely annoying.

When I searched the net I found many others having this kind of issue
with different fonts (like DejaVu Sans Mono), too, and I also found this
workaround

  https://www.reddit.com/r/emacs/comments/3zto22/i_sort_of_fixed_a_font_rendering_bug_of_emacs/

suggesting this patch:

--8<---------------cut here---------------start------------->8---
diff --git a/src/xftfont.c b/src/xftfont.c
index 110f99a..95e7e52 100644
--- a/src/xftfont.c
+++ b/src/xftfont.c
@@ -395,16 +395,16 @@ xftfont_open (struct frame *f, Lisp_Object entity, int pixel_size)
 
   font->ascent = xftfont->ascent;
   font->descent = xftfont->descent;
-  if (pixel_size >= 5)
-    {
-      /* The above condition is a dirty workaround because
-        XftTextExtents8 behaves strangely for some fonts
-        (e.g. "Dejavu Sans Mono") when pixel_size is less than 5. */
-      if (font->ascent < extents.y)
-       font->ascent = extents.y;
-      if (font->descent < extents.height - extents.y)
-       font->descent = extents.height - extents.y;
-    }
+  /* if (pixel_size >= 5) */
+  /*   { */
+  /*     /\* The above condition is a dirty workaround because */
+  /*    XftTextExtents8 behaves strangely for some fonts */
+  /*    (e.g. "Dejavu Sans Mono") when pixel_size is less than 5. *\/ */
+  /*     if (font->ascent < extents.y) */
+  /*   font->ascent = extents.y; */
+  /*     if (font->descent < extents.height - extents.y) */
+  /*   font->descent = extents.height - extents.y; */
+  /*   } */
   font->height = font->ascent + font->descent;
 
   if (XINT (AREF (entity, FONT_SIZE_INDEX)) == 0)
--8<---------------cut here---------------end--------------->8---

And indeed, that does solve the issue for me.  Now the regular and the
bold version are displayed with the same height.

I have no idea about font handling, so I cannot tell if the above DTRT.
However, it fixes an annoying issue that seems to happen only with
Emacs.  Somewhere on the net I've read that Emacs seems to be the only
one being correct, i.e., it displays what the font says, and if the bold
version of a font is higher than the regular one, that's a (mis)feature
of the font.

Anyhow, since the results can be annoying and apparently not so few
users are affected, can we have a customize option for that?

Bye,
Tassilo



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

* Re: Font height issue
  2016-02-25 19:34 Font height issue Tassilo Horn
@ 2016-02-25 19:49 ` Marcin Borkowski
  2016-02-25 20:04 ` Eli Zaretskii
  1 sibling, 0 replies; 4+ messages in thread
From: Marcin Borkowski @ 2016-02-25 19:49 UTC (permalink / raw
  To: Tassilo Horn; +Cc: emacs-devel


On 2016-02-25, at 20:34, Tassilo Horn <tsdh@gnu.org> wrote:

> Hi all,
>
> I have the problem that the font I want to use in Emacs (PragmataPro in
> size 10, sizes 9 or 11 seem to be not affected) seems to have slightly
> different heights in the regular and the bold version, or at least Emacs
> thinks so.  As a result, when modes change text to/from regular to bold
> or vice versa dynamically (e.g., show-paren-mode with a bold
> show-paren-match face), the height of the line changes which is
> extremely annoying.
>
> When I searched the net I found many others having this kind of issue
> with different fonts (like DejaVu Sans Mono), too, and I also found this
> workaround
>
>   https://www.reddit.com/r/emacs/comments/3zto22/i_sort_of_fixed_a_font_rendering_bug_of_emacs/
>
> suggesting this patch:
>
> --8<---------------cut here---------------start------------->8---
> diff --git a/src/xftfont.c b/src/xftfont.c
> index 110f99a..95e7e52 100644
> --- a/src/xftfont.c
> +++ b/src/xftfont.c
> @@ -395,16 +395,16 @@ xftfont_open (struct frame *f, Lisp_Object entity, int pixel_size)
>  
>    font->ascent = xftfont->ascent;
>    font->descent = xftfont->descent;
> -  if (pixel_size >= 5)
> -    {
> -      /* The above condition is a dirty workaround because
> -        XftTextExtents8 behaves strangely for some fonts
> -        (e.g. "Dejavu Sans Mono") when pixel_size is less than 5. */
> -      if (font->ascent < extents.y)
> -       font->ascent = extents.y;
> -      if (font->descent < extents.height - extents.y)
> -       font->descent = extents.height - extents.y;
> -    }
> +  /* if (pixel_size >= 5) */
> +  /*   { */
> +  /*     /\* The above condition is a dirty workaround because */
> +  /*    XftTextExtents8 behaves strangely for some fonts */
> +  /*    (e.g. "Dejavu Sans Mono") when pixel_size is less than 5. *\/ */
> +  /*     if (font->ascent < extents.y) */
> +  /*   font->ascent = extents.y; */
> +  /*     if (font->descent < extents.height - extents.y) */
> +  /*   font->descent = extents.height - extents.y; */
> +  /*   } */
>    font->height = font->ascent + font->descent;
>  
>    if (XINT (AREF (entity, FONT_SIZE_INDEX)) == 0)
> --8<---------------cut here---------------end--------------->8---
>
> And indeed, that does solve the issue for me.  Now the regular and the
> bold version are displayed with the same height.
>
> I have no idea about font handling, so I cannot tell if the above DTRT.
> However, it fixes an annoying issue that seems to happen only with
> Emacs.  Somewhere on the net I've read that Emacs seems to be the only
> one being correct, i.e., it displays what the font says, and if the bold
> version of a font is higher than the regular one, that's a (mis)feature
> of the font.
>
> Anyhow, since the results can be annoying and apparently not so few
> users are affected, can we have a customize option for that?

+1

I have the same problem.

> Bye,
> Tassilo

Best,

-- 
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Faculty of Mathematics and Computer Science
Adam Mickiewicz University



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

* Re: Font height issue
  2016-02-25 19:34 Font height issue Tassilo Horn
  2016-02-25 19:49 ` Marcin Borkowski
@ 2016-02-25 20:04 ` Eli Zaretskii
  2016-02-25 20:07   ` Tassilo Horn
  1 sibling, 1 reply; 4+ messages in thread
From: Eli Zaretskii @ 2016-02-25 20:04 UTC (permalink / raw
  To: Tassilo Horn; +Cc: emacs-devel

> From: Tassilo Horn <tsdh@gnu.org>
> Date: Thu, 25 Feb 2016 20:34:52 +0100
> 
> I have the problem that the font I want to use in Emacs (PragmataPro in
> size 10, sizes 9 or 11 seem to be not affected) seems to have slightly
> different heights in the regular and the bold version, or at least Emacs
> thinks so.  As a result, when modes change text to/from regular to bold
> or vice versa dynamically (e.g., show-paren-mode with a bold
> show-paren-match face), the height of the line changes which is
> extremely annoying.
> 
> When I searched the net I found many others having this kind of issue
> with different fonts (like DejaVu Sans Mono), too, and I also found this
> workaround
> 
>   https://www.reddit.com/r/emacs/comments/3zto22/i_sort_of_fixed_a_font_rendering_bug_of_emacs/
> 
> suggesting this patch:
> 
> --8<---------------cut here---------------start------------->8---
> diff --git a/src/xftfont.c b/src/xftfont.c
> index 110f99a..95e7e52 100644
> --- a/src/xftfont.c
> +++ b/src/xftfont.c
> @@ -395,16 +395,16 @@ xftfont_open (struct frame *f, Lisp_Object entity, int pixel_size)
>  
>    font->ascent = xftfont->ascent;
>    font->descent = xftfont->descent;
> -  if (pixel_size >= 5)
> -    {
> -      /* The above condition is a dirty workaround because
> -        XftTextExtents8 behaves strangely for some fonts
> -        (e.g. "Dejavu Sans Mono") when pixel_size is less than 5. */
> -      if (font->ascent < extents.y)
> -       font->ascent = extents.y;
> -      if (font->descent < extents.height - extents.y)
> -       font->descent = extents.height - extents.y;
> -    }
> +  /* if (pixel_size >= 5) */
> +  /*   { */
> +  /*     /\* The above condition is a dirty workaround because */
> +  /*    XftTextExtents8 behaves strangely for some fonts */
> +  /*    (e.g. "Dejavu Sans Mono") when pixel_size is less than 5. *\/ */
> +  /*     if (font->ascent < extents.y) */
> +  /*   font->ascent = extents.y; */
> +  /*     if (font->descent < extents.height - extents.y) */
> +  /*   font->descent = extents.height - extents.y; */
> +  /*   } */
>    font->height = font->ascent + font->descent;
>  
>    if (XINT (AREF (entity, FONT_SIZE_INDEX)) == 0)
> --8<---------------cut here---------------end--------------->8---
> 
> And indeed, that does solve the issue for me.  Now the regular and the
> bold version are displayed with the same height.

Sorry, this is bug #22383, where the conclusion was already reached
that the workaround was not needed anymore.  I thought the change was
committed, but I see that it wasn't, so I committed it now to the
emacs-25 branch.



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

* Re: Font height issue
  2016-02-25 20:04 ` Eli Zaretskii
@ 2016-02-25 20:07   ` Tassilo Horn
  0 siblings, 0 replies; 4+ messages in thread
From: Tassilo Horn @ 2016-02-25 20:07 UTC (permalink / raw
  To: Eli Zaretskii; +Cc: emacs-devel

Eli Zaretskii <eliz@gnu.org> writes:

Hi Eli,

>> And indeed, that does solve the issue for me.  Now the regular and
>> the bold version are displayed with the same height.
>
> Sorry, this is bug #22383, where the conclusion was already reached
> that the workaround was not needed anymore.  I thought the change was
> committed, but I see that it wasn't, so I committed it now to the
> emacs-25 branch.

Ah, you are right, and I can confirm that my issue is solved now.
Thanks a ton!

Bye,
Tassilo



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

end of thread, other threads:[~2016-02-25 20:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-25 19:34 Font height issue Tassilo Horn
2016-02-25 19:49 ` Marcin Borkowski
2016-02-25 20:04 ` Eli Zaretskii
2016-02-25 20:07   ` Tassilo Horn

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.