emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* org mode table alignment issue with CJK characters
@ 2023-03-23 14:44 Zelphir Kaltstahl
  2023-03-25 12:56 ` Zelphir Kaltstahl
  2023-03-25 17:55 ` Ihor Radchenko
  0 siblings, 2 replies; 5+ messages in thread
From: Zelphir Kaltstahl @ 2023-03-23 14:44 UTC (permalink / raw)
  To: emacs-orgmode


[-- Attachment #1.1: Type: text/plain, Size: 2402 bytes --]

Hello org mode users!

I recently looked into getting org mode tables to properly align cell borders 
and table border, when using Chinese characters in them.

I found out, that there is valign mode [1] and was happy with it for a few days. 
But then I opened a document with lots of tables and some of those tables bigger 
than what I had before in other documents. Scrolling inside that document became 
quite laggy. So teeth-gnashingly I deactivated valign mode, already suspecting 
it to be the culprit. And I was right. After deactivating it, I could scroll 
perfectly fine again.

So I returned to the second alternative I had found out about, when searching 
for a solution: Finding a font, which renders Chinese characters at exactly 
double the width of latin/ASCII characters. I found a font named "Sarasa" [2] 
and experimented a bit with setting the font globally, then setting it only when 
opening an org mode buffer. Now it looks like that font does character widths 
almost correctly (see attached screenshot, see slightly wider 4 ASCII characters 
than 2 Chinese characters).

My settings for org mode regarding fonts/faces are:

~~~~
(add-hook 'org-mode-hook
           (function
            (lambda ()
              ;; Only do the following in graphical mode, as it will
              ;; break when using emacs in terminal mode.
              (when (display-graphic-p)
                ;; Sarasa font is fromhttps://github.com/be5invis/Sarasa-Gothic.
                (setq buffer-face-mode-face
                      '(:family "Sarasa Mono CL"
                        :weight normal
                        :height 110))
                (buffer-face-mode)))))
~~~~

However, it seems, that now org mode does not align tables correctly, even 
though an ASCII character is half the width of a Chinese character in the 
tables. Org mode seems to add too few or too many spaces, which are displayed as 
spaces of various width.—Is that because of the 1 pixel width difference?

Do I need to look for another font, which does things truly exactly, no 1 pixel 
too wide funny business? Maybe someone knows a more exact font?

Ultimately: How can I make tables align correctly?

My Emacs version is: GNU Emacs 28.2

My org mode version is: 9.6.1

[1]: https://github.com/casouri/valign

[2]: https://github.com/be5invis/Sarasa-Gothic

-- 
repositories:https://notabug.org/ZelphirKaltstahl

[-- Attachment #1.2: Type: text/html, Size: 3169 bytes --]

[-- Attachment #2: emacs-font-rendering.png --]
[-- Type: image/png, Size: 91159 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-03-25 19:01 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-03-23 14:44 org mode table alignment issue with CJK characters Zelphir Kaltstahl
2023-03-25 12:56 ` Zelphir Kaltstahl
2023-03-25 17:55 ` Ihor Radchenko
2023-03-25 18:27   ` Zelphir Kaltstahl
2023-03-25 19:01     ` Ihor Radchenko

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).