all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Drew Adams" <drew.adams@oracle.com>
To: "'Jason Rumney'" <jasonr@gnu.org>, <1562@emacsbugs.donarmstrong.com>
Cc: emacs-pretest-bug@gnu.org
Subject: bug#1562: 23.0.60; modify-frame-parameters in Emacs 23 for fonts
Date: Sun, 14 Dec 2008 09:30:03 -0800	[thread overview]
Message-ID: <000a01c95e11$99e69410$0200a8c0@us.oracle.com> (raw)
In-Reply-To: <49451CBD.50108@gnu.org>

[-- Attachment #1: Type: text/plain, Size: 2905 bytes --]

> > (1) `modify-frame-parameters' changes the `font' parameter 
> > behind your back from the value you provide
> > `modify-frame-parameters':
> >
> > (modify-frame-parameters frame
> >   (list (cons 'font "-outline-Lucida Console-normal-normal-\
> > normal-mono-15-*-*-*-c-*-iso8859-1")))
> >
> > The `font' frame parameter is then:
> >
> > "-outline-Lucida Console-normal-normal-normal-mono-15-\
> > *-*-*-c-*-fontset-auto8"
> >
> > IOW, iso8859-1 gets replaced by fontset-auto8.
> 
> I don't see this. Please try with emacs -Q.

See attached file, bug-zoom.el.
emacs -Q, then load the file or eval it a sexp at a time if you want to see the
initial font name etc.

After loading, (frame-parameter nil 'font) gives
"-outline-Lucida Console-normal-normal-normal-mono-14-*-*-*-c-*-iso8859-1"

Then do `C-u 5 M-x enlarge-font'. (frame-parameter nil 'font) gives
"-outline-Lucida Console-normal-normal-normal-mono-19-*-*-*-c-*-iso8859-1"
which is correct.

Then do `C-u -5 M-x enlarge-font'. (frame-parameter nil 'font) gives
"-outline-Lucida Console-normal-normal-normal-mono-14-*-*-*-c-*-fontset-auto1"
which is NOT correct.

The code calls `modify-frame-parameters' with the same 14-point font name that
was returned initially, and which ends in "-iso8859-1", not "-fontset-auto1".
But that's not what the `font' parameter value is after the
`modify-frame-parameters' call.

`M-x debug-on-entry enlarge-font', and you will see, just after this call
(notice that the font name passed as argument is correct):

Debugger entered--returning value: nil
  modify-frame-parameters(#<frame emacs@DRADAMS-LAP1 0x2acf600> ((font .
"-outline-Lucida Console-normal-normal-normal-mono-14-*-*-*-c-*-iso8859-1")))

that (frame-parameter nil 'font) gives
"-outline-Lucida Console-normal-normal-normal-mono-14-*-*-*-c-*-fontset-auto1"
which is wrong.

(I also tried using `copy-sequence' to ensure that the string passed is a new
one etc. No improvement.)

Initially, I thought perhaps it had something to do with the call to
`query-fontset' in the commented-out piece of code in `enlarged-font-name',
since `query-fontset' returns a string with "-fontset-auto1" at the end. But the
bug remains, even with that code commented out.

Note too that over time, "-fontset-auto1" becomes "-fontset-auto2", and so on.

The bug seems to be in `modify-frame-parameters'.

FWIW, let me be clear why I would like this bug fixed. While waiting for the
fix, I hacked the code for Emacs 23 to just modify the :height attribute for the
`default' face. That is what most people do, to zoom a frame. That does not give
as many font/frame size possibilities as my code does - it is not as flexible.
So yes, I know there is a rudimentary workaround, but I would like this code to
work again, as it does in Emacs 20, 21, and 22. It doesn't seem right that
`modify-frame-parameters' modifies a frame differently from what you tell it to
do.


[-- Attachment #2: bug-zoom.el --]
[-- Type: application/octet-stream, Size: 1958 bytes --]

(modify-frame-parameters
 nil
 (list
  (cons 
   'font
   "-*-Lucida Console-normal-r-*-*-14-*-96-96-c-*-iso8859-1")))

(frame-parameter nil 'font)

(defun enlarge-font (&optional increment frame)
  "Increase size of font in FRAME by INCREMENT.
Interactively, INCREMENT is given by the prefix argument.
Optional FRAME parameter defaults to current frame."
  (interactive "p")
  (setq frame (or frame (selected-frame)))
  (let ((fontname (cdr (assq 'font (frame-parameters frame))))
        (count 100))
    (setq fontname (enlarged-font-name fontname frame increment))
    (while (and (not (x-list-fonts fontname)) (wholenump (setq count (1- count))))
      (setq fontname (enlarged-font-name fontname frame increment)))
    (unless (x-list-fonts fontname) (error "Cannot change font size"))
    (modify-frame-parameters frame (list (cons 'font fontname)))
    ;; Update faces that want a bold or italic version of the default font.
    (frame-update-faces frame)))

(defun enlarged-font-name (fontname frame increment)
  "FONTNAME, after enlarging font size of FRAME by INCREMENT.
FONTNAME is the font of FRAME."
;;   (when (query-fontset fontname)
;;     (let ((ascii (assq 'ascii (aref (fontset-info fontname frame) 2))))
;;       (when ascii (setq fontname (nth 2 ascii)))))
  (let ((xlfd-fields (x-decompose-font-name fontname)))
    (unless xlfd-fields (error "Cannot decompose font name"))
    (let ((new-size (+ (string-to-number (aref xlfd-fields xlfd-regexp-pixelsize-subnum))
                       increment)))
      (unless (> new-size 0) (error "New font size is too small: %s" new-size))
      (aset xlfd-fields xlfd-regexp-pixelsize-subnum (number-to-string new-size)))
    ;; Set point size & width to "*", so frame width will adjust to new font size
    (aset xlfd-fields xlfd-regexp-pointsize-subnum "*")
    (aset xlfd-fields xlfd-regexp-avgwidth-subnum "*")
    (x-compose-font-name xlfd-fields)))

  reply	other threads:[~2008-12-14 17:30 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <495C2629.40504@gnu.org>
2008-12-13 19:02 ` bug#1562: 23.0.60; modify-frame-parameters in Emacs 23 for fonts Drew Adams
2008-12-13 20:46   ` Glenn Morris
2008-12-13 21:21     ` Drew Adams
2008-12-14 14:48   ` Jason Rumney
2008-12-14 17:30     ` Drew Adams [this message]
2009-01-01  2:20   ` bug#1562: marked as done (23.0.60; modify-frame-parameters in Emacs 23 for fonts) Emacs bug Tracking System
     [not found] <4850FC42.7060305@gnu.org>
2008-04-06  2:17 ` modify-frame-parameters in Emacs 23 for fonts Drew Adams
     [not found]   ` <handler.119.C.121326703431170.notifdonectrl.0@emacsbugs.donarmstrong.com>
2008-06-12 14:50     ` bug#119 acknowledged by developer (Closing fixed bugs) Drew Adams
2008-06-12 16:11       ` Subject of closure notifications sent to submitters [Re: bug#119 acknowledged by developer (Closing fixed bugs)] Don Armstrong
2008-06-12 16:48         ` Subject of closure notifications sent to submitters [Re: bug#119acknowledged " Drew Adams
2008-06-12 17:27           ` Don Armstrong
2008-06-12 18:24             ` Subject of closure notifications sent to submitters [Re:bug#119acknowledged " Drew Adams
2008-06-12 18:32               ` Don Armstrong
2009-01-01  2:20   ` bug#119: marked as done (modify-frame-parameters in Emacs 23 for fonts) Emacs bug Tracking System
2008-06-12 10:45 ` Processed: Closing fixed bugs Emacs bug Tracking System

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='000a01c95e11$99e69410$0200a8c0@us.oracle.com' \
    --to=drew.adams@oracle.com \
    --cc=1562@emacsbugs.donarmstrong.com \
    --cc=emacs-pretest-bug@gnu.org \
    --cc=jasonr@gnu.org \
    /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.