dbordak/telephone-line

Support for changing font size

sebasmonia opened this issue · 5 comments

I have monitors with different resolutions, if I let Windows adjust the DPI there's blurry text in at least one of them. Instead I have a hook that changes the frame font size depending on the current monitor.

Seems like telephone-line can't adjust correctly to the change. I think it might be related to the cache for separators, as if I move the frame to another screen without splitting it then the inactive mode-line renders with the minimum height, but if I split first then both active and inactive look the same size.

I tried making the height part of the image cache key but that didn't quite work. If you give me a clue what could be causing this I can try to submit a PR.

2019-05-28 09_30_54-scratch - Emacs

I got it working by changing telephone-line-separator-render-image to this:

(cl-defmethod telephone-line-separator-render-image ((obj telephone-line-separator) foreground background)
  "Find cached pbm of OBJ in FOREGROUND and BACKGROUND.
If it doesn't exist, create and cache it."
  (let* ((height (or telephone-line-height (frame-char-height)))
         (hash-key (format "%s_%s_%s" background foreground height)))
    ;; Return cached image if we have it.
    (or (gethash hash-key (oref obj image-cache))
        (puthash hash-key
                 (telephone-line-propertize-image
                  (telephone-line--create-pbm-image
                   (telephone-line-separator-create-body obj)
                   background foreground))
                 (oref obj image-cache)))))

but now I get a small render defect in one of the monitors, see the attach.
(Also I think I should use something else to get the height, there's already a method define in utils to get the height but I was just testing :))
2019-05-28 09_57_13-Microsoft Edge

Strangely at work with 3 completely different resolutions (4K, retina-like, and laptop), it renders perfectly in all screens!

Oh, hey, adding font height to the cache key is a great idea.

Awesome. I have another PR in the pipeline (that as per another issue, could convert to a Wiki entry rather than MOAR SEGMENTS, up to you).

I won't add this to the same PR as they are completely different issues, but will submit one right after. Also, I think I need to call one of the methods defined instead of repeating the "height selection" logic.

This was merged in #104, closing the issue. Thank you!