From: Eli Zaretskii <eliz@gnu.org>
To: Jim Porter <jporterbugs@gmail.com>
Cc: R.Stewart@hw.ac.uk, 72771@debbugs.gnu.org, kevin.legouguec@gmail.com
Subject: bug#72771: 31.0.50; shr html renderer throwing "Specified window is not displaying the current buffer"
Date: Sun, 25 Aug 2024 08:05:49 +0300 [thread overview]
Message-ID: <868qwlmbte.fsf@gnu.org> (raw)
In-Reply-To: <5ae9ebbe-924a-5f8a-6630-12f009c96629@gmail.com> (message from Jim Porter on Sat, 24 Aug 2024 12:42:04 -0700)
> Date: Sat, 24 Aug 2024 12:42:04 -0700
> Cc: R.Stewart@hw.ac.uk, 72771@debbugs.gnu.org, kevin.legouguec@gmail.com
> From: Jim Porter <jporterbugs@gmail.com>
>
> >> I think the problem is getting the actual face, which works for simple
> >> cases via 'get-text-property', but not for more complex ones, e.g. when
> >> the 'face' property is a list; 'face-font' raises an error in that case.
> >> Effectively what I want would be a Lisp version of
> >> 'face_at_buffer_position', but that requires a window object anyway, so
> >> I'm back to the original problem...
> >
> > What's wrong with face-at-point?
>
> I don't know if that gets me quite what I want; it seems to be
> equivalent to 'get-text-property' for this case. The real problem is
> that I can't pass a list of faces to 'face-font'. In a case like that,
> any one of the faces in the list could be setting the font, so I can't
> just pass the first face in the list (or some other simplification).
>
> I'm sure I could iterate over the faces, but that seems more complex
> than the 'font-at' trick.
The 'font-at' trick might seem simple, but it has its caveats, as
mentioned before. You basically use settings of a wrong window. This
could be fine in simple cases, but not in all of them. For example,
there are window-specific overlays and other features.
> >>> . use buffer-text-pixel-size or string-pixel-width to measure the
> >>> width of a string of a single SPC character
> >>
> >> I think this wouldn't work since I want the average font width, not the
> >> width of SPC.
> >
> > Then use a few different characters and take their average width.
>
> Well, I just want the "average-width" parameter as reported by the font
> object (falling back to "space-width"), since Emacs has already computed
> that.
If you look at how this is computed, you will see that at least some
font backends do exactly what I said: they measure the width of a
string of different characters and divide that by the number of
characters.
> Trying to re-approximate that already-computed value doesn't seem
> like the right thing to do when I can jump over a small hurdle to get
> the existing value.
Again, the simplicity here is deceptive.
> > And I think you place too much faith in the average-width parameter of
> > a font. It can fail you. The display engine uses:
> >
> > char_width = (font->average_width
> > ? font->average_width
> > : font->space_width);
>
> Thanks for prompting me to re-read the manual on this. I'd
> misinterpreted this passage in the documentation for 'query-font':
>
> > average-width > The average width of the font characters. If this is zero, Emacs uses
> > the value of space-width instead, when it calculates text layout on
> > display.
>
> Previously I thought it meant that this element of the vector would hold
> the average-width, or if that was zero, hold (a copy of) the
> space-width. But checking the code, I see that's not right, and I should
> be sure to mimic what the display engine does above.
>
> Maybe this passage could be reworded to something like this: "This value
> may be zero. In that case, for calculating text layout on display,
> Emacs will consult the space-width instead."
I don't see how this is different from the text we already have,
sorry.
> >> In light of the above, I think what I have now might be the best way to
> >> do it for the time being
> >
> > Do you still think that?
>
> Aside from the above issue with 'space-width', yes (fixed in the
> attached patch).
<Shrug>Fine by me.
next prev parent reply other threads:[~2024-08-25 5:05 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-23 8:15 bug#72771: 31.0.50; shr html renderer throwing "Specified window is not displaying the current buffer" Rob Stewart via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-08-23 9:13 ` Rob Stewart via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-08-23 13:12 ` Eli Zaretskii
2024-08-23 17:10 ` Kévin Le Gouguec
2024-08-23 22:39 ` Jim Porter
2024-08-24 6:08 ` Eli Zaretskii
2024-08-24 17:10 ` Jim Porter
2024-08-24 19:01 ` Eli Zaretskii
2024-08-24 19:42 ` Jim Porter
2024-08-25 5:05 ` Eli Zaretskii [this message]
2024-08-25 6:11 ` Jim Porter
2024-08-25 6:22 ` Eli Zaretskii
2024-08-25 17:18 ` Jim Porter
2024-08-25 17:49 ` Eli Zaretskii
2024-08-25 18:51 ` Jim Porter
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=868qwlmbte.fsf@gnu.org \
--to=eliz@gnu.org \
--cc=72771@debbugs.gnu.org \
--cc=R.Stewart@hw.ac.uk \
--cc=jporterbugs@gmail.com \
--cc=kevin.legouguec@gmail.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 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.