Closed sorawee closed 3 years ago
Thanks for the report. Some related issues are here. Possibly this is related to the Racket Mode back end converting to SVG (rather than PNG). I'll have to investigate more.
I took a moment to reproduce this, but can't seem to, yet.
I tried changing the font size various ways, using:
text-scale-adjust
in the REPL buffer.text-scale-adjust
in the source buffer.(set-face-attribute 'default (selected-frame) :height height)
to change the base font size for the entire frame (a trick I use when moving between displays of different sizes and DPIs)I didn't see a change to the size of:
Can you say more which combination(s) cause the resize, for you?
p.s. I tried using Emacs 25.2.2 on Linux. You're using 27.2 on Mac. I wonder if that matters. e.g. Could there be a new feature where Emacs resizes images with the font? If so can it be disabled?
Ah, I just realized that cmd +
and cmd -
in my Emacs are bound to doom/increase-font-size
and doom/decrease-font-size
as defined here: https://github.com/hlissner/doom-emacs/blob/develop/core/autoload/fonts.el. So perhaps this is a Doom Emacs issue rather than Racket Mode's.
Glancing at that Doom code, it seems to change the frame's base font size (by a different method than what I mentioned, but I think the same effect).
Trying Emacs 28.0.50.0 snapshot I built locally:
Do you see the same distinction?
If so I think we're looking at the same underlying issue; this seems unrelated to Doom, and instead to a change in Emacs starting around 27.
I think Emacs 27 is when they replaced imagemagick with native support. Apparently this affects how Emacs loads/sizes the SVG files created by Racket Mode's back end, or something like that.
If that theory is correct, I guess I'll need to see how I might be able to compensate.
- The per-buffer text-scale commands do not change the size of images.
Changing the frame's base font size:
- does not change the size of existing images in the buffer
- does change the size of new images created thereafter by subsequent runs
Do you see the same distinction?
Yes and yes!
Other factoids:
Comparing doc strings for create-image
in Emacs 25.2.2 vs. 28.0.50.0, this phrase is added to the latter:
create-image is an autoloaded compiled Lisp function in ‘image.el’.
(create-image FILE-OR-DATA &optional TYPE DATA-P &rest PROPS)
Probably introduced at or before Emacs version 21.1.
Create an image. FILE-OR-DATA is an image file name or image data.
Optional TYPE is a symbol describing the image type. If TYPE is omitted or nil, try to determine the image type from its first few bytes of image data. If that doesn’t work, and FILE-OR-DATA is a file name, use its file extension as image type.
Optional DATA-P non-nil means FILE-OR-DATA is a string containing image data.
Optional PROPS are additional image attributes to assign to the image, like, e.g. ‘:mask MASK’. If the property ‘:scale’ is not given and the display has a high resolution (more exactly, when the average width of a character in the default font is more than 10 pixels), the image is automatically scaled up in proportion to the default font.
Value is the image created, or nil if images of type TYPE are not supported.
Images should not be larger than specified by ‘max-image-size’.
Image file names that are not absolute are searched for in the "images" sub-directory of ‘data-directory’ and ‘x-bitmap-file-path’ (in that order).
It seems like adding :scale 1.0
would avoid this behavior.
I'm not yet sure the downside.
I think my action plan needs to be doing some learning/thinking, first:
create-image
. It sounds like this might be part of a strategy for better hi-DPI support? Which seems well intentioned, at least; so "always disable it" (e.g. :scale 1.0
) might not be the best answer.I found time to look into this.
I convinced myself the correct thing to do here is simply supply the new :scale 1.0
property to create-image
.
I have a commit which I'll merge after tests pass.
In DrRacket, the program:
produces an image. I can increase/decrease font size, but evaluating the program will always produce the image with the same size.
However, in Racket Mode, evaluating the program when font size is large will produce a large circle, while evaluating the program when font size is small will produce a small circle.