[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#9949: 24.0.91; window-width function does not take text-scale-mode-a

From: Eli Zaretskii
Subject: bug#9949: 24.0.91; window-width function does not take text-scale-mode-amount into account
Date: Fri, 04 Nov 2011 22:12:06 +0200

> From: Josh <address@hidden>
> Date: Fri, 4 Nov 2011 11:30:10 -0700
> Cc: address@hidden
> > > (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.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]