* Display certain glyphs with paddings on the side @ 2019-11-30 19:51 Yuan Fu 2019-12-02 16:24 ` Eli Zaretskii 2019-12-02 18:34 ` 황병희 0 siblings, 2 replies; 17+ messages in thread From: Yuan Fu @ 2019-11-30 19:51 UTC (permalink / raw) To: Emacs developers Aligning ACSII characters with Chinese characters in Emacs has been a pain for me. The common solution (among Chinese community) is to scale Chinese characters with `face-font-rescale-alist’ and make one Chinese character precisely twice as wide as a ASCII character. However, that makes the Chinese characters taller than the ASCII characters. Is it possible to add some padding to the sides of a Chinese character and make it twice as wide in Emacs? Yuan ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: Display certain glyphs with paddings on the side 2019-11-30 19:51 Display certain glyphs with paddings on the side Yuan Fu @ 2019-12-02 16:24 ` Eli Zaretskii 2019-12-03 4:56 ` Richard Stallman 2019-12-03 16:42 ` Clément Pit-Claudel 2019-12-02 18:34 ` 황병희 1 sibling, 2 replies; 17+ messages in thread From: Eli Zaretskii @ 2019-12-02 16:24 UTC (permalink / raw) To: Yuan Fu; +Cc: emacs-devel > From: Yuan Fu <casouri@gmail.com> > Date: Sat, 30 Nov 2019 14:51:29 -0500 > > Aligning ACSII characters with Chinese characters in Emacs has been a pain for me. The common solution (among Chinese community) is to scale Chinese characters with `face-font-rescale-alist’ and make one Chinese character precisely twice as wide as a ASCII character. However, that makes the Chinese characters taller than the ASCII characters. Is it possible to add some padding to the sides of a Chinese character and make it twice as wide in Emacs? I don't think we have any such features. You will have to choose your fonts such that they provide this nice alignment. ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: Display certain glyphs with paddings on the side 2019-12-02 16:24 ` Eli Zaretskii @ 2019-12-03 4:56 ` Richard Stallman 2019-12-03 15:43 ` Eli Zaretskii 2019-12-03 16:42 ` Clément Pit-Claudel 1 sibling, 1 reply; 17+ messages in thread From: Richard Stallman @ 2019-12-03 4:56 UTC (permalink / raw) To: Eli Zaretskii; +Cc: casouri, emacs-devel [[[ To any NSA and FBI agents reading my email: please consider ]]] [[[ whether defending the US Constitution against all enemies, ]]] [[[ foreign or domestic, requires you to follow Snowden's example. ]]] >> Is it possible to add some padding >> to the sides of a Chinese character and make it twice as wide in >> Emacs? > I don't think we have any such features. You will have to choose your > fonts such that they provide this nice alignment. I don't think it would be terribly hard to implement such a feature, as features go. -- Dr Richard Stallman Founder, Free Software Foundation (https://gnu.org, https://fsf.org) Internet Hall-of-Famer (https://internethalloffame.org) ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: Display certain glyphs with paddings on the side 2019-12-03 4:56 ` Richard Stallman @ 2019-12-03 15:43 ` Eli Zaretskii 2019-12-03 15:49 ` Yuan Fu 0 siblings, 1 reply; 17+ messages in thread From: Eli Zaretskii @ 2019-12-03 15:43 UTC (permalink / raw) To: rms; +Cc: casouri, emacs-devel > From: Richard Stallman <rms@gnu.org> > Cc: casouri@gmail.com, emacs-devel@gnu.org > Date: Mon, 02 Dec 2019 23:56:22 -0500 > > >> Is it possible to add some padding > >> to the sides of a Chinese character and make it twice as wide in > >> Emacs? > > > I don't think we have any such features. You will have to choose your > > fonts such that they provide this nice alignment. > > I don't think it would be terribly hard to implement such a feature, > as features go. I'll welcome patches to that effect, of course. Personally, I don't think I have a clear idea what is the feature we should implement. First, how does users tell Emacs they want this to happen? Do we introduce some buffer-local variable or a minor mode? Next, what exactly should the feature do? override the width of each glyph with an integral multiple of the width of the default face's font? If so, what to do when the default face's font is not a fixed-pitch font? And should we do the same if the font to be widened is also larger in height (i.e. we are talking about something like chapter and section headings in Info)? IOW, I think we need first to come up with a detailed specification, so that we have a clear idea of what needs to be implemented. I encourage people to file a feature request bug report on debbugs. ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: Display certain glyphs with paddings on the side 2019-12-03 15:43 ` Eli Zaretskii @ 2019-12-03 15:49 ` Yuan Fu 0 siblings, 0 replies; 17+ messages in thread From: Yuan Fu @ 2019-12-03 15:49 UTC (permalink / raw) To: Eli Zaretskii; +Cc: rms, emacs-devel > I'll welcome patches to that effect, of course. > > Personally, I don't think I have a clear idea what is the feature we > should implement. First, how does users tell Emacs they want this to > happen? Do we introduce some buffer-local variable or a minor mode? > > Next, what exactly should the feature do? override the width of each > glyph with an integral multiple of the width of the default face's > font? If so, what to do when the default face's font is not a > fixed-pitch font? And should we do the same if the font to be widened > is also larger in height (i.e. we are talking about something like > chapter and section headings in Info)? > > IOW, I think we need first to come up with a detailed specification, > so that we have a clear idea of what needs to be implemented. I > encourage people to file a feature request bug report on debbugs. > I don’t think I’m skilled enough to provide a patch, but I will think about this feature and report a more detailed feature request. Thanks, Yuan ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: Display certain glyphs with paddings on the side 2019-12-02 16:24 ` Eli Zaretskii 2019-12-03 4:56 ` Richard Stallman @ 2019-12-03 16:42 ` Clément Pit-Claudel 2019-12-03 17:38 ` Eli Zaretskii 1 sibling, 1 reply; 17+ messages in thread From: Clément Pit-Claudel @ 2019-12-03 16:42 UTC (permalink / raw) To: emacs-devel On 2019-12-02 11:24, Eli Zaretskii wrote: >> From: Yuan Fu <casouri@gmail.com> >> Date: Sat, 30 Nov 2019 14:51:29 -0500 >> >> Aligning ACSII characters with Chinese characters in Emacs has been a pain for me. The common solution (among Chinese community) is to scale Chinese characters with `face-font-rescale-alist’ and make one Chinese character precisely twice as wide as a ASCII character. However, that makes the Chinese characters taller than the ASCII characters. Is it possible to add some padding to the sides of a Chinese character and make it twice as wide in Emacs? > > I don't think we have any such features. You will have to choose your > fonts such that they provide this nice alignment. This is the approach that I've been using in a different context. I use programming languages with heavy reliane on mathematical symbols, so I have patched versions of mathematical fonts to ensure that symbols line up nicely with monospace characters. The python code that does these transformations is here: https://github.com/cpitclaudel/monospacifier I think Emacs might have most of the features needed already as part of the composition engine, but applying the right composition properties to each character would be costly and complicated. Clément. ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: Display certain glyphs with paddings on the side 2019-12-03 16:42 ` Clément Pit-Claudel @ 2019-12-03 17:38 ` Eli Zaretskii 2019-12-03 18:36 ` Yuri Khan 2019-12-03 18:43 ` Clément Pit-Claudel 0 siblings, 2 replies; 17+ messages in thread From: Eli Zaretskii @ 2019-12-03 17:38 UTC (permalink / raw) To: Clément Pit-Claudel; +Cc: emacs-devel > From: Clément Pit-Claudel <cpitclaudel@gmail.com> > Date: Tue, 3 Dec 2019 11:42:03 -0500 > > I think Emacs might have most of the features needed already as part of the composition engine No, character composition does nothing to the width of glyphs on display. We take the width from the glyph metrics reported by the font. ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: Display certain glyphs with paddings on the side 2019-12-03 17:38 ` Eli Zaretskii @ 2019-12-03 18:36 ` Yuri Khan 2019-12-03 18:42 ` Eli Zaretskii 2019-12-03 18:43 ` Clément Pit-Claudel 1 sibling, 1 reply; 17+ messages in thread From: Yuri Khan @ 2019-12-03 18:36 UTC (permalink / raw) To: Eli Zaretskii; +Cc: Clément Pit-Claudel, Emacs developers On Wed, 4 Dec 2019 at 01:13, Eli Zaretskii <eliz@gnu.org> wrote: > > I think Emacs might have most of the features needed already as part of the composition engine > > No, character composition does nothing to the width of glyphs on > display. We take the width from the glyph metrics reported by the > font. I use composition in prettify-symbols-mode to render a symbol in a two-space field, e.g. to visualize a ‘!=’ sequence as a '(?\s (Br . Bl) ?\s (Bc . Bc) ?≠) composition. Pretty sure that any CJK glyph, if its width is less than two spaces, can also be padded that way. No idea how to arrange for the compositions to be used for all CJK characters though. ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: Display certain glyphs with paddings on the side 2019-12-03 18:36 ` Yuri Khan @ 2019-12-03 18:42 ` Eli Zaretskii 0 siblings, 0 replies; 17+ messages in thread From: Eli Zaretskii @ 2019-12-03 18:42 UTC (permalink / raw) To: Yuri Khan; +Cc: cpitclaudel, emacs-devel > From: Yuri Khan <yuri.v.khan@gmail.com> > Date: Wed, 4 Dec 2019 01:36:05 +0700 > Cc: Clément Pit-Claudel <cpitclaudel@gmail.com>, > Emacs developers <emacs-devel@gnu.org> > > On Wed, 4 Dec 2019 at 01:13, Eli Zaretskii <eliz@gnu.org> wrote: > > I use composition in prettify-symbols-mode to render a symbol in a > two-space field, e.g. to visualize a ‘!=’ sequence as a '(?\s (Br . > Bl) ?\s (Bc . Bc) ?≠) composition. Pretty sure that any CJK glyph, if > its width is less than two spaces, can also be padded that way. No > idea how to arrange for the compositions to be used for all CJK > characters though. That's easy, but how do you know which glyphs need to be padded and by how much? And anyway, doing layout from Lisp is generally not a good idea: at best you will have slow and fragile layout. ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: Display certain glyphs with paddings on the side 2019-12-03 17:38 ` Eli Zaretskii 2019-12-03 18:36 ` Yuri Khan @ 2019-12-03 18:43 ` Clément Pit-Claudel 2019-12-03 19:13 ` Eli Zaretskii 1 sibling, 1 reply; 17+ messages in thread From: Clément Pit-Claudel @ 2019-12-03 18:43 UTC (permalink / raw) To: Eli Zaretskii; +Cc: emacs-devel On 2019-12-03 12:38, Eli Zaretskii wrote: >> From: Clément Pit-Claudel <cpitclaudel@gmail.com> >> Date: Tue, 3 Dec 2019 11:42:03 -0500 >> >> I think Emacs might have most of the features needed already as part of the composition engine > > No, character composition does nothing to the width of glyphs on > display. We take the width from the glyph metrics reported by the > font. For the OP's purpose, I think character composition is "enough", in the sense that it can be used to display a glyphs with padding on the sides (as far as I know, composition can't be used to shrink a glyph, however). Concretely, I'm think of this: (insert (compose-string "a" 0 1 '(?\s (br . bl) ?\s (bc . bc) ?我))) If I'm reading the spec correctly, this should draw the character 我 with padding on both sides to reach the width of two spaces (assuming the choice of fonts is such as 我 is narrower than two spaces to being with). Clément. ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: Display certain glyphs with paddings on the side 2019-12-03 18:43 ` Clément Pit-Claudel @ 2019-12-03 19:13 ` Eli Zaretskii 2019-12-03 20:00 ` Clément Pit-Claudel 0 siblings, 1 reply; 17+ messages in thread From: Eli Zaretskii @ 2019-12-03 19:13 UTC (permalink / raw) To: Clément Pit-Claudel; +Cc: emacs-devel > Cc: emacs-devel@gnu.org > From: Clément Pit-Claudel <cpitclaudel@gmail.com> > Date: Tue, 3 Dec 2019 13:43:33 -0500 > > > No, character composition does nothing to the width of glyphs on > > display. We take the width from the glyph metrics reported by the > > font. > > For the OP's purpose, I think character composition is "enough", in the sense that it can be used to display a glyphs with padding on the sides (as far as I know, composition can't be used to shrink a glyph, however). > > Concretely, I'm think of this: > > (insert (compose-string "a" 0 1 '(?\s (br . bl) ?\s (bc . bc) ?我))) > > If I'm reading the spec correctly, this should draw the character 我 with padding on both sides to reach the width of two spaces (assuming the choice of fonts is such as 我 is narrower than two spaces to being with). This isn't really workable in practice. First, you'd need to do this for every CJK character, which means redisplay will be much slower for them (since character composition calls Lisp from the display engine, and will have to references a huge char-table). Second, not all CJK characters need to be padded, and you have no easy way of knowing that from Lisp, certainly no fast way. And third, you assume that the width of the space is identical to the width of other characters, which may be true for many fonts, but not for all of them. IOW, as I said in another message, doing layout in Lisp will get you rotten layout. It is only "good enough" for simplistic subsets of the real-life problems, IME. ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: Display certain glyphs with paddings on the side 2019-12-03 19:13 ` Eli Zaretskii @ 2019-12-03 20:00 ` Clément Pit-Claudel 2019-12-04 1:22 ` Yuan Fu 2019-12-04 3:41 ` Eli Zaretskii 0 siblings, 2 replies; 17+ messages in thread From: Clément Pit-Claudel @ 2019-12-03 20:00 UTC (permalink / raw) To: Eli Zaretskii; +Cc: emacs-devel On 2019-12-03 14:13, Eli Zaretskii wrote: >> Cc: emacs-devel@gnu.org >> From: Clément Pit-Claudel <cpitclaudel@gmail.com> >> Date: Tue, 3 Dec 2019 13:43:33 -0500 >> >>> No, character composition does nothing to the width of glyphs on >>> display. We take the width from the glyph metrics reported by the >>> font. >> >> For the OP's purpose, I think character composition is "enough", in the sense that it can be used to display a glyphs with padding on the sides (as far as I know, composition can't be used to shrink a glyph, however). >> >> Concretely, I'm think of this: >> >> (insert (compose-string "a" 0 1 '(?\s (br . bl) ?\s (bc . bc) ?我))) >> >> If I'm reading the spec correctly, this should draw the character 我 with padding on both sides to reach the width of two spaces (assuming the choice of fonts is such as 我 is narrower than two spaces to being with). > > This isn't really workable in practice. Sorry, my point wasn't that the OP should do that; rather, I was pointing out that the display engine was powerful enough to achieve the desired result. Ideally, what I'd love to have is a mode that implements a grid-like layout, where each character occupies an exact multiple of the base character width, regardless of which font it comes from. Deciding what this multiple should be for each character could be done in various ways; for my purposes (and for OP's case as well, I think), it would be enough to use one cell for halfwidth characters, two for fullwidth characters, and add a few exceptions for things like TAB and zero-width spaces (I'm using the terms fullwidth and halfwidth in the sense of https://www.unicode.org/reports/tr11/). Should I open a bug report about this? Cheers, Clément. ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: Display certain glyphs with paddings on the side 2019-12-03 20:00 ` Clément Pit-Claudel @ 2019-12-04 1:22 ` Yuan Fu 2019-12-04 3:41 ` Eli Zaretskii 1 sibling, 0 replies; 17+ messages in thread From: Yuan Fu @ 2019-12-04 1:22 UTC (permalink / raw) To: Clément Pit-Claudel; +Cc: Eli Zaretskii, emacs-devel [-- Attachment #1: Type: text/plain, Size: 1359 bytes --] > > Ideally, what I'd love to have is a mode that implements a grid-like layout, where each character occupies an exact multiple of the base character width, regardless of which font it comes from. > > Deciding what this multiple should be for each character could be done in various ways; for my purposes (and for OP's case as well, I think), it would be enough to use one cell for halfwidth characters, two for fullwidth characters, and add a few exceptions for things like TAB and zero-width spaces (I'm using the terms fullwidth and halfwidth in the sense of https://www.unicode.org/reports/tr11/ <https://www.unicode.org/reports/tr11/>). > Clément expressed the idea better than I could have. However, I’d like to see it as a face attribute instead of a mode. (Because I want to align my org table). Maybe there could be a face attribute (:grid WIDTH) that instructs the display engine to pad each glyph to have width that is a multiple of WIDTH in pixel, and if WIDTH is t, default to “base character width”? I remembered that ‘window-width’ gives width in char widths and had a look at its source. It knows the character width from FRAME_COLUMN_WIDTH; the comment says the value currently equals to the average width of the default font of the frame. I think this value can be used as the “base character width”. Yuan [-- Attachment #2: Type: text/html, Size: 5520 bytes --] ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: Display certain glyphs with paddings on the side 2019-12-03 20:00 ` Clément Pit-Claudel 2019-12-04 1:22 ` Yuan Fu @ 2019-12-04 3:41 ` Eli Zaretskii 1 sibling, 0 replies; 17+ messages in thread From: Eli Zaretskii @ 2019-12-04 3:41 UTC (permalink / raw) To: Clément Pit-Claudel; +Cc: emacs-devel > Cc: emacs-devel@gnu.org > From: Clément Pit-Claudel <cpitclaudel@gmail.com> > Date: Tue, 3 Dec 2019 15:00:19 -0500 > > Should I open a bug report about this? Yes, please. As I said, we need a more detailed specification for how the feature will be defined and used. ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: Display certain glyphs with paddings on the side 2019-11-30 19:51 Display certain glyphs with paddings on the side Yuan Fu 2019-12-02 16:24 ` Eli Zaretskii @ 2019-12-02 18:34 ` 황병희 2019-12-03 15:51 ` Yuan Fu 1 sibling, 1 reply; 17+ messages in thread From: 황병희 @ 2019-12-02 18:34 UTC (permalink / raw) To: Emacs developers Yuan Fu <casouri@gmail.com> writes: > Aligning ACSII characters with Chinese characters in Emacs has been a > pain for me. The common solution (among Chinese community) is to scale > Chinese characters with `face-font-rescale-alist’ and make one Chinese > character precisely twice as wide as a ASCII character. However, that > makes the Chinese characters taller than the ASCII characters. Is it > possible to add some padding to the sides of a Chinese character and > make it twice as wide in Emacs? Or, you would be using Google Noto CJK font. Below is example for Google Noto CJK font: #+BEGIN_SRC text HANGANG 漢江 한강 #+END_SRC The screenshot here: https://gitlab.com/soyeomul/Gnus/raw/master/ss/Screenshot_from_2019-12-03_03-28-35.png Sincerely, -- ^고맙습니다 _地平天成_ 감사합니다_^))// ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: Display certain glyphs with paddings on the side 2019-12-02 18:34 ` 황병희 @ 2019-12-03 15:51 ` Yuan Fu 2019-12-03 22:33 ` 황병희 0 siblings, 1 reply; 17+ messages in thread From: Yuan Fu @ 2019-12-03 15:51 UTC (permalink / raw) To: 황병희; +Cc: Emacs developers > > Or, you would be using Google Noto CJK font. > > Below is example for Google Noto CJK font: > #+BEGIN_SRC text > HANGANG 漢江 한강 > #+END_SRC Thanks. But I don’t see the alignment between the CJK glyph and ASCII glyph in your screenshot. What effects are you achieving by using Google Noto CJK font? Yuan ^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: Display certain glyphs with paddings on the side 2019-12-03 15:51 ` Yuan Fu @ 2019-12-03 22:33 ` 황병희 0 siblings, 0 replies; 17+ messages in thread From: 황병희 @ 2019-12-03 22:33 UTC (permalink / raw) To: Emacs developers [-- Attachment #1: Type: text/plain, Size: 215 bytes --] Hello, Yuan^^^ > [...] What effects are you achieving by using > Google Noto CJK font? I would say that your case will be resolving by font change. And Google Noto CJK font is better than other font. Sincerely, [-- Attachment #2: CJK font Good^^^ --] [-- Type: image/png, Size: 394856 bytes --] [-- Attachment #3: Type: text/plain, Size: 62 bytes --] -- ^고맙습니다 _地平天成_ 감사합니다_^))// ^ permalink raw reply [flat|nested] 17+ messages in thread
end of thread, other threads:[~2019-12-04 3:41 UTC | newest] Thread overview: 17+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2019-11-30 19:51 Display certain glyphs with paddings on the side Yuan Fu 2019-12-02 16:24 ` Eli Zaretskii 2019-12-03 4:56 ` Richard Stallman 2019-12-03 15:43 ` Eli Zaretskii 2019-12-03 15:49 ` Yuan Fu 2019-12-03 16:42 ` Clément Pit-Claudel 2019-12-03 17:38 ` Eli Zaretskii 2019-12-03 18:36 ` Yuri Khan 2019-12-03 18:42 ` Eli Zaretskii 2019-12-03 18:43 ` Clément Pit-Claudel 2019-12-03 19:13 ` Eli Zaretskii 2019-12-03 20:00 ` Clément Pit-Claudel 2019-12-04 1:22 ` Yuan Fu 2019-12-04 3:41 ` Eli Zaretskii 2019-12-02 18:34 ` 황병희 2019-12-03 15:51 ` Yuan Fu 2019-12-03 22:33 ` 황병희
Code repositories for project(s) associated with this public inbox https://git.savannah.gnu.org/cgit/emacs.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).