GNU bug report logs -
#17813
24.3.91; bad linum display with `text-scale-adjust'
Previous Next
Reported by: Shigeru Fukaya <shigeru.fukaya <at> gmail.com>
Date: Thu, 19 Jun 2014 17:27:02 UTC
Severity: normal
Found in version 24.3.91
Done: Stefan Monnier <monnier <at> iro.umontreal.ca>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 17813 in the body.
You can then email your comments to 17813 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#17813
; Package
emacs
.
(Thu, 19 Jun 2014 17:27:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Shigeru Fukaya <shigeru.fukaya <at> gmail.com>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Thu, 19 Jun 2014 17:27:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Font size of line numbers by `linum-mode' follow `text-scale-adjust', though
the size of left margin doesn't change.
(nlinum also has the same problem)
The possible solutions are,
(1) To change the width of left margin for line numbers.
[attached patch]
(2) To fix the font size of line numbers.
(set-face-attribute 'linum nil :height (face-attribute 'linum :height nil t))
Solution (2) may need more in case of multi frames with different font size.
Regards,
Shigeru
[linum.diff (application/octet-stream, attachment)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#17813
; Package
emacs
.
(Thu, 19 Jun 2014 18:47:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 17813 <at> debbugs.gnu.org (full text, mbox):
> Font size of line numbers by `linum-mode' follow `text-scale-adjust', though
> the size of left margin doesn't change.
> (nlinum also has the same problem)
> The possible solutions are,
> (1) To change the width of left margin for line numbers.
> (2) To fix the font size of line numbers.
I think the right solution is to scale the margin width by the ratio
"linum font size / base font size". Then users can set their `linum'
face the way want and choose between (1) and (2).
But it turns out that face-attribute can't be used for that because it
does not pay attention to face-remapping-alist.
Miles, Eli, others, do you know of a function that returns "the font
size, including face-remapping-alist effects"?
Stefan
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#17813
; Package
emacs
.
(Fri, 20 Jun 2014 09:32:02 GMT)
Full text and
rfc822 format available.
Message #11 received at 17813 <at> debbugs.gnu.org (full text, mbox):
> From: Stefan Monnier <monnier <at> iro.umontreal.ca>
> Date: Thu, 19 Jun 2014 14:46:48 -0400
> Cc: 17813 <at> debbugs.gnu.org, miles <at> gnu.org
>
> I think the right solution is to scale the margin width by the ratio
> "linum font size / base font size". Then users can set their `linum'
> face the way want and choose between (1) and (2).
>
> But it turns out that face-attribute can't be used for that because it
> does not pay attention to face-remapping-alist.
Not sure what you mean by that: attributes don't care about remapping,
because remapping doesn't change the attributes, it only changes their
values.
> Miles, Eli, others, do you know of a function that returns "the font
> size, including face-remapping-alist effects"?
I think you want
(aref (font-info (face-font 'default)) 2)
But note that font's size and its "width" (which is actually the
average width recorded in the font file) are not identical. We don't
have a Lisp API to get the average width of a non-default font;
perhaps we should.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#17813
; Package
emacs
.
(Fri, 20 Jun 2014 13:36:01 GMT)
Full text and
rfc822 format available.
Message #14 received at 17813 <at> debbugs.gnu.org (full text, mbox):
>> I think the right solution is to scale the margin width by the ratio
>> "linum font size / base font size". Then users can set their `linum'
>> face the way want and choose between (1) and (2).
>> But it turns out that face-attribute can't be used for that because it
>> does not pay attention to face-remapping-alist.
> Not sure what you mean by that: attributes don't care about remapping,
> because remapping doesn't change the attributes, it only changes their
> values.
I mean the following:
a way to know "if I apply face `foo' (and only face `foo') to a chunk
of text in the current buffer, what will it look like: will it be bold?
what will be its size? ..."
`face-attribute' doesn't work here because it fails to take into account
the effect of face-remapping-alist.
>> Miles, Eli, others, do you know of a function that returns "the font
>> size, including face-remapping-alist effects"?
> I think you want
> (aref (font-info (face-font 'default)) 2)
Indeed, that seems to work, thanks.
> But note that font's size and its "width" (which is actually the
> average width recorded in the font file) are not identical. We don't
> have a Lisp API to get the average width of a non-default font;
Indeed, that's an additional problem.
> perhaps we should.
I'm all for it.
Stefan
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#17813
; Package
emacs
.
(Fri, 20 Jun 2014 14:29:01 GMT)
Full text and
rfc822 format available.
Message #17 received at 17813 <at> debbugs.gnu.org (full text, mbox):
> From: Stefan Monnier <monnier <at> iro.umontreal.ca>
> Cc: shigeru.fukaya <at> gmail.com, 17813 <at> debbugs.gnu.org, miles <at> gnu.org
> Date: Fri, 20 Jun 2014 09:35:32 -0400
>
> >> I think the right solution is to scale the margin width by the ratio
> >> "linum font size / base font size". Then users can set their `linum'
> >> face the way want and choose between (1) and (2).
> >> But it turns out that face-attribute can't be used for that because it
> >> does not pay attention to face-remapping-alist.
> > Not sure what you mean by that: attributes don't care about remapping,
> > because remapping doesn't change the attributes, it only changes their
> > values.
>
> I mean the following:
>
> a way to know "if I apply face `foo' (and only face `foo') to a chunk
> of text in the current buffer, what will it look like: will it be bold?
> what will be its size? ..."
>
> `face-attribute' doesn't work here because it fails to take into account
> the effect of face-remapping-alist.
APIs that need to take face remapping into account need to be
specifically programmed to do that. Some were, some weren't;
face-font belongs to the former.
> > (aref (font-info (face-font 'default)) 2)
>
> Indeed, that seems to work, thanks.
>
> > But note that font's size and its "width" (which is actually the
> > average width recorded in the font file) are not identical. We don't
> > have a Lisp API to get the average width of a non-default font;
>
> Indeed, that's an additional problem.
>
> > perhaps we should.
>
> I'm all for it.
Would it be OK to add that as the last element to the array returned
by font-info?
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#17813
; Package
emacs
.
(Fri, 20 Jun 2014 15:36:02 GMT)
Full text and
rfc822 format available.
Message #20 received at 17813 <at> debbugs.gnu.org (full text, mbox):
> Would it be OK to add that as the last element to the array returned
> by font-info?
Sounds fine to me, but I know very little about font handling.
I do know that the face/font code uses various arrays that don't all
have the same length but share the same meaning for the first elements,
so of course, we should first make sure that adding an element to the
array doesn't break other parts.
Stefan
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#17813
; Package
emacs
.
(Tue, 08 Jul 2014 19:35:01 GMT)
Full text and
rfc822 format available.
Message #23 received at 17813 <at> debbugs.gnu.org (full text, mbox):
Version:24.5
> (1) To change the width of left margin for line numbers.
> [attached patch]
I installed the patch below instead (I earlier used a similar patch for
nlinum), which should be slightly more robust. Thank you,
Stefan
=== modified file 'lisp/linum.el'
--- lisp/linum.el 2014-02-10 01:34:22 +0000
+++ lisp/linum.el 2014-07-08 19:27:00 +0000
@@ -138,6 +138,9 @@
(mapc #'delete-overlay linum-available)
(setq linum-available nil))))
+(defun linum--face-height (face)
+ (aref (font-info (face-font face)) 2))
+
(defun linum-update-window (win)
"Update line numbers for the portion visible in window WIN."
(goto-char (window-start win))
@@ -178,6 +181,12 @@
(let ((inhibit-point-motion-hooks t))
(forward-line))
(setq line (1+ line)))
+ (when (display-graphic-p)
+ (setq width (ceiling
+ ;; We'd really want to check the widths rather than the
+ ;; heights, but it's a start.
+ (/ (* width 1.0 (linum--face-height 'linum))
+ (frame-char-height)))))
(set-window-margins win width (cdr (window-margins win)))))
(defun linum-after-change (beg end _len)
bug closed, send any further explanations to
17813 <at> debbugs.gnu.org and Shigeru Fukaya <shigeru.fukaya <at> gmail.com>
Request was from
Stefan Monnier <monnier <at> iro.umontreal.ca>
to
control <at> debbugs.gnu.org
.
(Tue, 08 Jul 2014 19:35:02 GMT)
Full text and
rfc822 format available.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Wed, 06 Aug 2014 11:24:04 GMT)
Full text and
rfc822 format available.
This bug report was last modified 10 years and 326 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.