laurent22 / joplin

Joplin - the privacy-focused note taking app with sync capabilities for Windows, macOS, Linux, Android and iOS.
https://joplinapp.org
Other
45.99k stars 5k forks source link

The v1.0.179/193 windows desktop app handles Chinese quote signal “” incorrectly. #2674

Closed metorm closed 4 years ago

metorm commented 4 years ago

Environment

Joplin version: v1.0.179/193 Platform: Windows OS specifics: Windows 10 x64

Steps to reproduce

  1. Open the desktop app
  2. New or go to any note
  3. Type some content containing Chinese characters and Chinese quote signal “”, eg 我说:“Joplin是个很不错的APP啊。”
  4. You will find that the text cursor is not at the correct position. Perhaps the text cursor thinks the Chinese quote signal takes exactly 1 unit width, but the display module knows that the signal shall take 2 unit width. See this gif.

Describe what you expected to happen

The editor should put the text cursor at the right position.

The previous version seems to handle this well, and all Chinese characters, signal except and are being well processed, no reason and cannot be handled.

Logfile

It's just an editor problem, I believe a log file is unnecessary.

liyang85 commented 4 years ago

I have the same problem with Joplin for macOS:

image

For Chinese characters, Joplin has other issues, such as wrap a sentence at SPACE, which is a wrong place. Below is a screenshot:

image

metorm commented 4 years ago

Update 2020-3-9 11:00:20

The recent update v1.0.193 didn't fix the issue. The problem still exists.

metorm commented 4 years ago

Update 2:

Not only the sign, but also the "℃" sign is also incorrectly handled in a similar way. I think we may need to maintain a list ...

metorm commented 4 years ago

Update 3:

Using the open-source font 等距更纱黑体 SC temporarily solves the problem. It's reported that the font may cause other rendering problems in Joplin, but my test shows that it's ok for now.

I think it's not a perfect solution, but we can live with it temporarily.

liyang85 commented 4 years ago

@metorm As you can see the 2nd screenshot in my previous post, I'm using 等距更纱黑体 SC (aka Sarasa Gothic) in Joplin for macOS.

At first, the reason for selecting this font is to get a correctly aligned Markdown table when the table has Chinese characters.

Fortunately, I never see the L-SEP symbol when I use Chinese Input Method.

But after seeing your latest post in this issue, I can tell you the Sarasa Gothic font indeed is a temporarily solution. Because many Chinese punctuations cannot be processed correctly, such as the Chinese ellipsis ……, Joplin editor might think the width of this symbol equals to the English ellipsis ... and place the cursor after the 3rd dot (…|…), which is a wrong position.

Even worse is, if a line includes a Chinese ellipsis, when the cursor is afterwards the ellipsis, its position always is wrong. This makes me crazy, and I only can do is removed the punctuation at last. So frustrated.

metorm commented 4 years ago

Well, at lease …… is used less frequently than “” ……

This post claimed that the problem can be solved by custom CSS. I haven't tested his method yet.

Another temporary solution is to use a third-party editor.

Anyway, the perfect solution is always to fix it inside Joplin.

liyang85 commented 4 years ago

Hi @metorm , thank you for the information.

I'm sorry but custom CSS and specific fonts are not my taste, I like an out-of-box app. If an app need to be hacked to do something which it should do, I think the app doesn't fit my needs.

For CJK characters, as you talked, there are many excellent Markdown editors can handle them perfectly, and Joplin supports external editors. Even the built-in React-Ace editor can do most of the editing works properly.

For now, I think I can accept some minor bugs of Joplin, because it can bring other major benefits at the same time, such as:

sinkuu commented 4 years ago

I suspect this is Ace editor's problem that it does not handle East Asian Width correctly. (https://github.com/ajaxorg/ace/issues/4208)

My manual workaround is patching Ace's isFullWidth function to cover EAW ambiguous width characters: https://gist.github.com/sinkuu/8dac3edeecdbbb5ada8560fda5f4cc57.

liyang85 commented 4 years ago

@sinkuu Would you like to share the steps of your manual patch? Thanks.

I have searched in the macOS app directory by using the find and grep commands, but I didn't find a function called isFullWidth or the same file edit_session.js from the ACE project which contains the function.

Then I have searched in the Joplin repository by using Sourcegraph, but I didn't find that file or function too.

sinkuu commented 4 years ago

@liyang85 Ace's source code is not contained in this repository.

OK, I've made a patch file. Download brace+0.11.1.patch and put it into joplin/patches directory. Then build Electron Client. Use this branch.

Note that this patch is only an imcomplete workaround. It does not work with the fonts where Ace's default behavior (ambiguous width = 1) is correct.

liyang85 commented 4 years ago

@sinkuu Thank you for your patient. I'm sorry but I don't want to build or compile Joplin on my computer. The reason I have talked in my previous post that I like an out-of-box app. Hope you can understand.

On the other hand, I think the development of Joplin is very active, if you can submit a pull request to this project, there are a lot of users will be benefited. Thanks again.

sinkuu commented 4 years ago

This workaround will break the editor for non-CJK environment:( This is really a makeshift and I don't want to add this thing to any project. I'm sorry.

Applications should not have assumptions based on codepoints about how characters are rendered in browser. The right and sane way is to revive https://github.com/ajaxorg/ace/pull/2002. Or replace Ace with CodeMirror or Monaco...

liyang85 commented 4 years ago

OK, got it.

As the leader @laurent22 of the Joplin project said on 5 Dec 2019 (https://github.com/laurent22/joplin/issues/275#issuecomment-561868840):

... Indeed the entire editor needs to be changed, which I hope will be done some day. I'm hoping that Code Mirror 6, if it's ever released, would be a good replacement as it could also be used on mobile.

We all hope the day comes very soon.

stale[bot] commented 4 years ago

Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may comment on the issue and I will leave it open. Thank you for your contributions.

metorm commented 4 years ago

The issue is not fixed yet.

stale[bot] commented 4 years ago

Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may comment on the issue and I will leave it open. Thank you for your contributions.

metorm commented 4 years ago

The issue is not fixed yet.

stale[bot] commented 4 years ago

Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may comment on the issue and I will leave it open. Thank you for your contributions.

stale[bot] commented 4 years ago

Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please feel free to create a new issue with up-to-date information.