johnfactotum / foliate

Read e-books in style
https://johnfactotum.github.io/foliate/
GNU General Public License v3.0
6.4k stars 293 forks source link

RTL Vertical Chinese epub punctuation rendering question #422

Closed hyhchan closed 4 years ago

hyhchan commented 4 years ago

Don't know if this is related to foliate or setting, but it seems that the full width punctuation rendering is different from epub.js and foliate.

Below is a screen cap from foliate:

Screenshot from 2020-06-02 11-16-08

And this is the same book opened in epub.js example/input.html on a locally built epub.js

Screenshot from 2020-06-02 11-15-39

2 things to note:

  1. The colon at the end of the first line on the right. The epub.js rendering is correct while the foliate rendering is wrong. Usually the rule of thumb is that all full width characters (word, alphanumeric characters, punctuation) will rotate vertically while half width characters will stay sideways. I noticed that somehow full width colon is the only punctuation that is not rotated.
  2. the rest of the punctuation marks, the epub.js rendering is better as everything is nice and centered after rotation, but in foliate comma and period (the little circle) is put at the upper right. It is not wrong but more of a cosmetic issue.

I tried setting several different fonts in foliate but it seems the same.

johnfactotum commented 4 years ago

I think it is a font issue. For example, with Source Han Serif:

image

But if you use Source Han Serif TC, then the punctuation is centered:

image

In the case of Source Han Serif, the font does include different glyphs for different languages. If the lang attribute is set correctly, it should use different glyphs with different languages. But this does not appear to have any effect in WebKitGTK. So this might be a WebKitGTK bug.

I think ideally we should add the option to set a different font for each language.

hyhchan commented 4 years ago

Thanks. Yes it is a font issue. Somehow my system defaulted to a Japanese font with a weird end colon. After selecting another font for TC it works.

digitalethics commented 4 years ago

Somehow my system defaulted to a Japanese font with a weird end colon. After selecting another font for TC it works.

I'm interested in this as a learner of the Chinese language. Do you have any recommendations of fonts that you particularly like for their typography? @hyhchan

I think ideally we should add the option to set a different font for each language.

@johnfactotum What happens if a particular font is not present on the system? Would it make sense to bundle it with Foliate if it is not shipped by distribution maintainers by default? Would that even work?

Perhaps we could reopen this issue to track suggestions for a good Chinese default font?

johnfactotum commented 4 years ago

I don't think it's practicable to ship fonts with Foliate. Font packages are huge, and a lot of people don't need support for a lot of languages, so even distros often don't install non-Latin fonts by default for that reason. Maybe we can bundle a default, nicer font than Serif (which I think on most system defaults to Deja Vu Serif -- personally I think it looks fine), but bundling a CJK font is simply a bad idea because they can get really huge (several hundred MB) in size. I guess you can bundle a slimmed down version, but there's no point in doing that since the user can easily install and use any font they like from the distro repo or manually, and those who would need it most likely would have already had one installed. Also note that many books already have embedded fonts.

Also, I don't think it's technically possible to ship custom fonts with Foliate, because Foliate uses GTK's font chooser, and, AFAIK, we cannot add custom fonts to it because fontconfig doesn't support GObject introspection, so we can't access it in GJS (if anyone knows a good way to do that I would be very interested to know).

hyhchan commented 4 years ago

@digitalethics Sorry I don't really have a preference on fonts, etc. I am more concern on the correct representation of the text since I am using Chinese ebooks to let my kids learn Chinese and having the books to be rendered in a correct way is hugely important for me. Nowadays most systems has most language installed and the default usually works well. For my case I think I installed some for CJK extension of some applications and got installed a font that has a wrong rendition of the colon, and somehow foliate mapped that font as default. It didn't show up in all my other programs so I didn't realize that it is the font problem. Off topics a bit, the way punctuation marks are put at the corners is more a Japanese way, although mainland China also adopted the use (but many mainland Chinese books are printed horizontally, which run against the tradition). Traditional Chinese (HK, Taiwan) would put the marks at the center. And believe it or not, modern Chinese punctuation marks only has 100 or so years of use. It was first promoted by scholars in the 1910s and 1920s. Ancient Chinese text didn't use punctuation much.

digitalethics commented 4 years ago

I am using Chinese ebooks to let my kids learn Chinese and having the books to be rendered in a correct way is hugely important for me.

Thanks for sharing! I don't mind reading some easy Chinese ebooks to brush up my reading comprehension. Maybe you can share some Chinese-language (or language learning related) OPDS links that could even be added as defaults (so that others can discover it too) if @johnfactotum agrees?

I have some ideas in the pipeline how Foliate could be more of an educational tool, especially in regards to learning Chinese and tutoring others in any other reading-intensive subject. What would be helpful for me (and I'm sure for anyone who reads Chinese ebooks to learn the language) is a way to add a feature to see the stroke order of Chinese characters in an animated form when hovering over or clicking on a character. Another idea is to offer a way to export annotations or highlighted text to Anki, a spaced repetition programme. I haven't quite finished reading up about these topics but will make a new feature request when I have some more specific ideas how this could be realized and what projects could be utilized for implementing this. Would you be interested in something like this for your kids? If yes, then I'd ping you when I get to write this up.

digitalethics commented 4 years ago

I guess you can bundle a slimmed down version, but there's no point in doing that since the user can easily install and use any font they like from the distro repo or manually

Maybe we can aggregate information on fonts and typography and add it to the wiki so that users can discover fonts that will improve their reading experience for specific use cases. I remember there was a project that would even depict Chinese characters in conjunction with the pinyin romanization. The benefit for language learners would be immense. Of course, this font does not come preinstalled on any distribution and I doubt it is even in any repositories.

I don't think it's technically possible to ship custom fonts with Foliate, because Foliate uses GTK's font chooser, and, AFAIK, we cannot add custom fonts to it because fontconfig doesn't support GObject introspection, so we can't access it in GJS (if anyone knows a good way to do that I would be very interested to know).

I'm not sure if this is in any way helpful but here's an idea: Do you think it would make sense to create a "font repository" on a server and allow users to browse this repository from within Foliate and enable or disable them via your proposed plugin architecture? Another fascinating idea would be to be able to render Chinese texts in different calligraphic styles and switch between them by clicking a button or via a keyboard shortcut.

johnfactotum commented 4 years ago

I remember there was a project that would even depict Chinese characters in conjunction with the pinyin romanization.

That's not really a good idea since a character very often has several different pronunciations.

I'm not sure if this is in any way helpful but here's an idea: Do you think it would make sense to create a "font repository" on a server and allow users to browse this repository

I think that would be out of the scope of Foliate.