New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use property align-to indent title pixel width #404
Conversation
…ot alignment like expect.
Here is screenshot before apply patch https://ibb.co/RDzxScK CJK char indent after apply patch https://ibb.co/pJz4z74 |
I'm indeed seeing improved behavior when the frame is wide: But no improvement when the frame is thin, where entry titles are truncated: I also don't like that the space between entry title and feed title is gone, but that could probably be fixed by prefixing titles with a space. I tested with https://www.tofugu.com/feed (the first thing I could find), but feel free to suggest any other feeds for testing. |
This is because A value that is complicated but near to the original behavior is:
The pixel length of multi-bytes CJK characters is less than the pixel length of equal-bytes spaces (i.e. CJK titles are shorter). So this should be fine. |
@skeeto I commit new patch to make align-to property works with thin window. |
@manateelazycat The newest commit still have defect on wide screen |
Done |
@skeeto Can you merge this patch? Thanks. |
In the current version on my machine non-CJK entries are now staggered,
and CJK entries still aren't working right at some widths. The position of
the feed title varies greatly depending on the font weight (i.e. unread
vs. read), and at thinner widths entry titles are cut off well before the
feed title. I'm testing using "make virtual" and just accepting the
default fonts, etc.
In order for me to merge the current behavior for non-CJK must be
absolutely unaffected, "make check" must be completely clean (no
warnings), and the new CJK behavior must be objectively better (no
regressions).
I appreciate your effort, Andy, but I suspect this is an essentially
unresolvable issue related to the way Emacs renders certain fonts. Elfeed
already uses string-width (rather than string length) to determine the
display width for titles and such, and so everything is already aligned
correctly for fonts where wide CJK glyphs are exactly two columns wide.
When I run Elfeed in a terminal, CJK is already lined up correctly since
my terminal is rendering the glyphs in the straightforward way. The pixel
alignment stuff will never work in terminal Emacs, and so it will always
be complete.
Here's a similar struggle with lining up tables in Org:
https://emacs.stackexchange.com/questions/19808/align-columns-in-org-mode-table-with-japanese-fonts
|
FYI. I am using the following function to determine displayed pixel
width of a string in graphical Emacs. Hope it can be helpful.
(defun string-display-pixel-width (string &optional mode)
"Calculate pixel width of STRING.
Optional MODE specifies major mode used for display."
(with-temp-buffer
(with-silent-modifications
(setf (buffer-string) string))
(when (fboundp mode)
(funcall mode)
(font-lock-fontify-buffer))
(if (get-buffer-window (current-buffer))
(car (window-text-pixel-size nil (line-beginning-position) (point)))
(set-window-buffer nil (current-buffer))
(car (window-text-pixel-size nil (line-beginning-position) (point))))))
|
If title include CJK font, title won't alignment like export, because Chinese char is not same width as English char.
This patch use align-to force title indent width special pixel.