GNU bug report logs -
#9949
24.0.91; window-width function does not take text-scale-mode-amount into account
Previous Next
Reported by: Josh <josh <at> foxtail.org>
Date: Fri, 4 Nov 2011 02:44:02 UTC
Severity: normal
Merged with 13073
Found in version 24.0.91
Done: Eli Zaretskii <eliz <at> gnu.org>
Bug is archived. No further changes may be made.
Full log
Message #25 received at 9949-done <at> debbugs.gnu.org (full text, mbox):
> From: Josh <josh <at> foxtail.org>
> Date: Fri, 4 Nov 2011 11:30:10 -0700
> Cc: 9949 <at> debbugs.gnu.org
>
> > > (defun scaled-window-width ()
> > > (destructuring-bind (left top right bottom) (window-inside-pixel-edges)
> > > (/ (- right left) (face-pixel-width))))
> > >
> > > Unfortunately, I could not find anything like face-pixel-width. Is this
> > > information exposed somehow or could it be made so?
> >
> > You could move point by 1 character and subtract pixel coordinates
> > returned by posn-at-point.
>
>
> I'd prefer to avoid the save-excursion-and-move-point dance so I could
> avoid checking conditions like being at start or end of buffer, whether
> forward-char actually moved horizontally or did it go to the next line,
> etc. This approach also wouldn't work in buffers that were empty, for
> example in a find-file-hook on a new file, because we can't move the point
> without modifying the buffer. It would be much simpler and more reliable
> to expose faces' pixel widths.
I suggest to ask for advice on help-gnu-emacs or emacs-devel, then.
> > But given that a line can have characters of different width, even for
> > the same face (think proportional fonts), what good will this kind of
> > functionality be?
> >
>
> window-width already returns incorrect results for the exceptions you
> mentioned. A variant that accounts for text scaling would be correct in
> all the cases window-width is correct, plus the case where text scaling has
> been applied to a fixed width font. All that is needed is for someone to
> expose the pixel width of a face and my scaled-window-width function above
> will work.
Feel free to file a feature-request bug about that.
I'm closing this one.
This bug report was last modified 12 years and 221 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.