cadadr / elisp

Göktuğ's Emacs Lisp programs
79 stars 21 forks source link

org-variable-pitch.el: How to handle font size discrepancies between fixed-pitch and variable-pitch fonts #52

Closed cadadr closed 1 year ago

cadadr commented 4 years ago

With some configurations the fixed pitch and variable pitch parts of the Org mode buffer may end up being of different font sizes. This was initially reported as part of the discussion for bug #51 (see esp. https://github.com/cadadr/elisp/issues/51#issuecomment-681909102, https://github.com/cadadr/elisp/issues/51#issuecomment-682414670, and https://github.com/cadadr/elisp/issues/51#issuecomment-682419015).

While differences between font families should be playing a role here, it seems like OVP could be something to remedy some cases too. As I'm not very knowledgeable on how fonts work exactly, inside Emacs or outside, comments on 1) your experience if you have a similar problem, 2) on what might be the possible causes of this issue, and 3) on how it could be solved or the situation ameliorated are welcome.

cc @terlar @ThibautVerron

ThibautVerron commented 4 years ago

Maybe this could be asked on emacs-devel.

The expected behavior of text scaling seems to be to change the size of default, and subsequently of every other face relatively to it (using a function as a height property, as @terlar mentioned).

See: https://github.com/jwiegley/emacs-release/blob/adfd5933358fdf6715423dee8169eb3cd7d982db/lisp/face-remap.el#L251-L256

  (setq text-scale-mode-remapping
    (and text-scale-mode
         (face-remap-add-relative 'default
                      :height
                      (expt text-scale-mode-step
                        text-scale-mode-amount))))

For some reason in our case everything seems to be scaled relative to the variable-pitch face instead of the default one. But the code above really says "the face 'default", not "whatever face is the current default one". So it could be an Emacs bug that mixed-pitch does not play well with zooming (or intuitively with setting sizes).

Maybe adding a similar relative remapping to ovp-fixed-face (together with inheriting the initial size from 'default) would work?

terlar commented 4 years ago

The reason why you see this behavior is due to how variable-pitch-mode works, when enabled it pairs the face variable-pitch with default. It is using the buffer-face-mode under the hood given the face variable-pitch.

(define-minor-mode buffer-face-mode
  "Minor mode for a buffer-specific default face.

When enabled, the face specified by the variable
`buffer-face-mode-face' is used to display the buffer text."
  :lighter " BufFace"
  (when buffer-face-mode-remapping
    (face-remap-remove-relative buffer-face-mode-remapping))
  (setq buffer-face-mode-remapping
    (and buffer-face-mode
         (face-remap-add-relative 'default buffer-face-mode-face)))
  (force-window-update (current-buffer)))
cadadr commented 1 year ago

OVP no longer maintained, cf. b28a70665b8db82323b57c2ee2f6e019cb9b92d3