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
Support config to control width of ambiguous width characters #1049
Conversation
This does not work properly because it breaks assumptions made about cell width. All characters should always restrict themselves to the grid system, not change their width on a whim. The only way to change the width of a cell would be by making a character occupy multiple cells, however this would still break things like copying selections and possible others that would need to be fixed for that case. |
d1a93da
to
ea2e679
Compare
I understand it is bad to make character width (number of cells a character occupies) changeable at run time. Now the |
ea2e679
to
cdb57ff
Compare
This is not about changing at runtime or not. It simply doesn't work to have cells that have different widths. All cells need to have the same width. |
current alacritty (master) handles full-width characters correctly, by using https://github.com/jwilm/alacritty/blob/59b561b440060e7b0d13160fb69519d127e6c687/src/term/mod.rs#L1240-L1241 (This is already implemented and I think this is not what you say "cells that have different width". Am I right?) My patch doesn't intend to change cell width, but intends to change characters width. https://github.com/jwilm/alacritty/pull/1049/files#diff-7b3174257e73247b46a5a32b142d45be This patch doesn't change the way how alacritty handles (counts, renders, etc.) characters considered as half-width or full-width. |
I've tested your code and ran into some issues with unicode characters. They did not all have the same width but instead randomly had bigger and smaller gaps. |
hmm... this PR shouldn't change behaviour for characters which are I want to reproduce and check what's happening. |
No this is font awesome's tux. Which is U+f17c. Part of the private use area. |
https://play.rust-lang.org/?gist=98a64a9829708cf0fc1922bc0cb0a3e1&version=stable |
It is not monospaced, however it should not completely break rendering when a non-monospaced font is rendered. The result of rendering a non-monospaced font should either be large gaps because the character is too small, or glyphs colliding with each other. Under no circumstances should this completely break font rendering in alacritty. |
Do you use
So, the problem is:
For CJK fonts users, the former (width = 2) is expected and latter (zsh) is doing wrong. Could you try same string with |
(Sorry, zsh has actually a bug, but the cause is not only that.) Bash uses system You should use In (maybe glibc's) default |
Users should (and may want to) use
For usual non-CJK users,
For CJK users (including me):
This pull request (and non-default config value) is only for users in specific conditions (who already have rendering problem), not for all users in any environment. (I'm sorry I'm not good at English...) |
Well assuming this just uses normal numbers, the display in a grid system should work properly. Have you checked if it's possible to do this through font metrics instead of just assuming the width based on codepoint? In theory the font should report the width of those characters as double the normal width when they are wide characters. |
I think that using font metrics won't solve this problem, because this is not only an issue of rendering.
The first condition is quite important, but it doesn't rely on actual glyph width of the selected font. In my environment with alacritty master, applications consider that the ambiguous width characters (such as In your environment, tux is considered to be half-width (I think. If in doubt, please run this locally to test).
To detect appropriate config (width function) automatically, alacritty should use system's |
I understand those problems and you are trying to minimize the change, but well, I think above statement is opposite. I believe It seems using font metrics ( If you can wait for me for a week or so, I can give the idea a try. (I am currently traveling abroad for business and will be back to home in a week.) |
In #1294 someone mentioned that our unicode width library does not support Unicode 10, might this be an issue why the width is not set properly? |
Unicode 10 support by newer (EDIT: inserted "NOT", sorry for confusing mistake...) If alacritty uses system wcwidth (#1295), then the correct characters width data for each environment will be used, and the problem will be solved. |
Ah, okay. Seems like the best solution is following through with #1295 then! Thanks for the clarification. |
cdb57ff
to
47f75e0
Compare
47f75e0
to
8f6d392
Compare
8f6d392
to
a3f1b1e
Compare
a3f1b1e
to
090bf9e
Compare
090bf9e
to
c90689d
Compare
c90689d
to
9bbe870
Compare
9bbe870
to
b45147b
Compare
b45147b
to
0c0be17
Compare
0c0be17
to
3511721
Compare
d05c2ff
to
fde8e3b
Compare
fde8e3b
to
03ddb5c
Compare
03ddb5c
to
d0a88b6
Compare
Closing because the solution proposed in #1295 is preferred. Thanks for your work, sorry for not being able to include it in this form! |
Fonts for some languages (mainly CJK) expects east asian width characters to be full-width.
This pull request provides a way to let users choose width for such characters.
For example, Ricty font with
east_asian_fullwidth: true
, seems correct:Ricty font with
east_asian_fullwidth: false
:east_asian_fullwidth: false
is behaviour before this PR (and default config value).In this example,
…
has full-width for the font but treated as half-width on terminal, so display is broken and cursor doesn't works correctly.