takaxp / moom

A Moom port to Emacs - Make your dominant hand FREE from your mouse
GNU General Public License v3.0
76 stars 3 forks source link

Wrong font selection after rescale #26

Open jenspets opened 1 year ago

jenspets commented 1 year ago

When resizing the font, unicode letters like æ, ø, and å is changed into the moom-font--ja font instead of moom-font--ascii. This means that unicode characters in most European languages will be displayed in the wrong font and size after scaling.

This can be repeated when using org-tree-slide with moom, and after moom-toggle-frame-maximized, the font and size of these letters are wrong, as can be seen with M-x moom-font-print-name-at-point

takaxp commented 1 year ago

Thank you for reporting the possible bug. Font setting is not easy task for covering all Emacs user so I think it is good to introduce a flag to apply JP font or not. Honestly speaking, this package is designed basically for me as Japanese user... but anyway I'll resolve this issue.

jenspets commented 1 year ago

Thanks for your quick reply, and thanks for making such a good package.

I can see that fonts are challenging to work with, especially with all variations and preferences that exist. Any change can break someone's workflow.

takaxp commented 1 year ago

Hi. I've just applied a tiny modification to the code which will firstly apply JP font configuration and secondly apply ASCII font so that JP font configuration will not overwrite that of ASCII font. Could you try the updated moom-font.el version 1.4.1. The change may resolve the issue but I'm not sure.

jenspets commented 1 year ago

Hi, I tried the newest version, and the font is correct when rescaling using moom-toggle-frame-maximized, but I found two other peculiarities:

  1. The Unicode characters are not scaling using C-mousewheel, but non-unicode characters are. Both are scaling properly when using moom-font-increase/decrease, though.
  2. moom-font--ascii is used when starting emacs with an org-mode file, but moom-font--ja is used when opening emacs with any other file, such as .emacs, source code files, text files, or starting without opening a file. The font is not changed after the initial open, so if I open emacs, then C-x C-f test.org, then moom-font--ja is still used, but if starting emacs with emacs test.org, moom-font--ascii is used.

But thanks for fixing the font selection issue for unicode characters at least.

takaxp commented 1 year ago

For the first item , the following code will resolve your issue when using mouse wheel. But for the second one, it is little bit hard to guess the way to workaround because it is unclear for me what is happen in booting sequence with/without Emacs, it depends on when (moom-mode 1) is executed or other functions in hooks regarding org and moom...

(defun my-mouse-wheel-text-scale (event)
  "Adjust font size of the default face according to EVENT.
`moon-font-increase' or `moom-font-decrease' is used."
  (interactive (list last-input-event))
  (let ((selected-window (selected-window))
        (scroll-window (mouse-wheel--get-scroll-window event))
        (button (mwheel-event-button event)))
    (select-window scroll-window 'mark-for-redisplay)
    (unwind-protect
        (cond ((memq button (list mouse-wheel-down-event
                                  mouse-wheel-down-alternate-event))
               (moom-font-increase 1))
              ((memq button (list mouse-wheel-up-event
                                  mouse-wheel-up-alternate-event))
               (moom-font-decrease 1)))
      (select-window selected-window))))
(advice-add 'mouse-wheel-text-scale :override #'my-mouse-wheel-text-scale)