Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
emacs
emacs
Commits
1cef6541
Commit
1cef6541
authored
Apr 09, 2003
by
Juanma Barranquero
Browse files
(set-frame-font): Allow keeping frame size after changing font.
parent
f979dc05
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
11 deletions
+25
-11
lisp/frame.el
lisp/frame.el
+25
-11
No files found.
lisp/frame.el
View file @
1cef6541
...
...
@@ -794,20 +794,34 @@ If FRAME is omitted, describe the currently selected frame."
(
cdr
(
assq
'width
(
frame-parameters
frame
))))
(
defalias
'set-default-font
'set-frame-font
)
(
defun
set-frame-font
(
font-name
)
(
defun
set-frame-font
(
font-name
&optional
keep-size
)
"Set the font of the selected frame to FONT-NAME.
When called interactively, prompt for the name of the font to use.
To get the frame's current default font, use `frame-parameters'."
To get the frame's current default font, use `frame-parameters'.
The default behavior is to keep the numbers of lines and columns in
the frame, thus may change its pixel size. If optional KEEP-SIZE is
non-nil (interactively, prefix argument) the current frame size (in
pixels) is kept by adjusting the numbers of the lines and columns."
(
interactive
(
list
(
let
((
completion-ignore-case
t
))
(
completing-read
"Font name: "
(
mapcar
#'
list
;; x-list-fonts will fail with an error
;; if this frame doesn't support fonts.
(
x-list-fonts
"*"
nil
(
selected-frame
)))))))
(
modify-frame-parameters
(
selected-frame
)
(
list
(
cons
'font
font-name
)))
(
let*
((
completion-ignore-case
t
)
(
font
(
completing-read
"Font name: "
(
mapcar
#'
list
;; x-list-fonts will fail with an error
;; if this frame doesn't support fonts.
(
x-list-fonts
"*"
nil
(
selected-frame
))))))
(
list
font
current-prefix-arg
)))
(
let
(
fht
fwd
)
(
if
keep-size
(
setq
fht
(
*
(
frame-parameter
nil
'height
)
(
frame-char-height
))
fwd
(
*
(
frame-parameter
nil
'width
)
(
frame-char-width
))))
(
modify-frame-parameters
(
selected-frame
)
(
list
(
cons
'font
font-name
)))
(
if
keep-size
(
modify-frame-parameters
(
selected-frame
)
(
list
(
cons
'height
(
round
fht
(
frame-char-height
)))
(
cons
'width
(
round
fwd
(
frame-char-width
)))))))
(
run-hooks
'after-setting-font-hook
'after-setting-font-hooks
))
(
defun
set-frame-parameter
(
frame
parameter
value
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment