Subject: Re: bug#26958: Can we make wavy underlines scale like straight ones?

From: Clément Pit--Claudel <[email-masked]>
Date: Wed, 17 May 2017 00:36:47 -0400

On 2017-05-17 00:14, Drew Adams wrote:
>> Straight underlines get thicker when font size increases, but wavy
>> underlines do not.  The problem is particularly visible on hi-resolution
>> displays, where wavy underlines look really tiny. This problem can be
>> observed on all displays by running the following and pressing C-x C-= a few
>> times:
>>
>> (font-lock-mode -1)
>> (insert (propertize "AAAAA" 'face '(:underline (:style line)))
>>         "\n" (propertize "AAAAA" 'face '(:underline (:style wave))))
> 
> FWIW, on Windows I see neither straight nor wavy underline thicken.
> They both continue to have the same line width (thickness) when
> text-scaled.
> 
> Should they not stay the same?  Should they thicken?  Why?

Thanks for the reply! They do scale in GNU/Linux; the code in xftfont says:

      font->underline_position = -ft_face->underline_position * size / upEM;
      font->underline_thickness = ft_face->underline_thickness * size / upEM;

The corresponding code in w32font says:

      font->underline_thickness = metrics->otmsUnderscoreSize;
      font->underline_position = -metrics->otmsUnderscorePosition;

which might be missing the scaling?

> I'm not on a "highdpi", I imagine.  But why should that make
> difference as to whether an underline should change thickness
> as the text is scaled?

That's the behavior I see on every other program that (I checked and that) supports underlines on my machine: Thunderbird (which also scales wavy underlines used to indicate spelling errors), Firefox, Chromium, and Libre Office Writer (which used to not scale spell-checking underlines, though this is partly fixed — see bug 90793).

> What about :overline?  It has no :wavy property, but should
> it too thicken when the text is scaled up?
> 
> And :box?  :box has a :line-width property.  Is that relevant
> here?  What should the behavior be for :box?  What should it
> be for attributes such as :underline or :overline or
> :strike-through, which don't have a :line-width property?
> 
> It doesn't seem as if the right design is obvious.

Judging by what web browsers do, they should all scale.

> Note that the first URL you cite does not ask necessarily for
> the wavy underline to scale.  It explicitly asks about
> customizing to specify the line width.
> 
> Maybe that's what the enhancement request should be: provide
> :line-width for :underline, like we do for :box.  And perhaps
> for :overline and :strike-through?

I made a separate request for (a limited version of) this.

> The first question is whether such line widths should respond
> to scaling.  Dunno.

I expect they should, based on looking at web browsers (and plenty of other programs — including Emacs ^^ — in the case of underlines).  But it's not only a thickness issue: it's also a positioning issue (the relative space between the text and the underline should be constant).

Clément.