Skip to content
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

What can support Chinese? #5

Open
ruchengtang opened this issue Aug 18, 2014 · 5 comments
Open

What can support Chinese? #5

ruchengtang opened this issue Aug 18, 2014 · 5 comments
Labels

Comments

@ruchengtang
Copy link

I like this tool, but not support Chinese.

@abrookins abrookins added the bug label Sep 5, 2014
@abrookins
Copy link
Owner

Can you give me some example text, the expected output and the actual output, so I can debug this? I added a very simple test to demonstrate that Chinese is wrapped at the column width, but other than that, I'm not sure what the problem is. https://github.com/abrookins/WrapToColumn/blob/master/src/com/andrewbrookins/idea/wrap/CodeWrapperTest.java#L98

Thanks!

@ruchengtang
Copy link
Author

wraptocolumn

achieve the effect of the picture as you can, usually used when writing Markdown or reStructuredText format documents.

test: 它是如何工作的呢?实际上,每个bundle在定义自己的服务配置都是跟目前为止你看到的是一样的。换句话说,一个bundle使用一个或者多个配置资源文件(通常是XML)来指定bundle所需要的参数和服务。然而,我们不直接在配置文件中使用 imports 命令导入它们,而是仅仅在bundle中调用一个服务容器扩展来为我们做同样的工作。一个服务容器扩展是 bundle 的作者创建的一个PHP类,它主要完成两件事情:

@abrookins
Copy link
Owner

Ah, yes, I see the problem now. The code is wrapping at 80 characters, but this doesn't account for the real size each code point takes up on the line. I will dig into this in my spare time.

@abrookins
Copy link
Owner

I looked into this problem more. Basically the font glyphs are variable-width, but Intellij's right margin guide (the visual bar) and the reflow algorithm in this plugin are based on monospaced characters.

Even though Intellij shows a right margin guide, it's positioned based on the width of a line of monospaced characters -- so Chinese glyphs are shown as spilling over the margin even if the characters, when considered as single-column width (i.e. monospace) are in total narrower than the right margin.

The only way I could think to wrap variable width text correctly would be to reflow it based on its display width (using something like Swing's FontMetrics) and the visual position of the right margin guide. That doesn't seem worth the effort to me, though I might pick it up again someday. Instead of doing that, I've added an explicit mention about variable width fonts to the README explaining that wrapping them probably won't work correctly.

@abrookins
Copy link
Owner

This is not as simple as I thought. Even while treating Chinese characters as taking a single column, the wrapping algorithm performs poorly because it considers only the space character as a word separator.

@abrookins abrookins reopened this Dec 14, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants