Skip to content
This repository was archived by the owner on Mar 3, 2023. It is now read-only.

CJK soft wrap - #9162

Merged
nathansobo merged 23 commits into
masterfrom
as-cjk-soft-wrap
Oct 16, 2015
Merged

nathansobo merged 23 commits into
masterfrom
as-cjk-soft-wrap

Conversation

@as-cii

@as-cii as-cii commented Oct 15, 2015

Copy link
Copy Markdown
Contributor

Instead of considering every character to have the same width when we perform soft-wrapping, we now make a distinction between default characters, double width characters, half width characters and Korean characters .

The strategy consists in measuring these kinds of characters once when sampling font styles and then using the calculated width to find where a certain line wraps.

Please, note that this won't work with non-monospaced fonts, but it's consistent with how we currently handle soft-wrapping for latin characters.

/cc: @nathansobo @maxbrunsfeld

@benogle

benogle commented Oct 15, 2015

Copy link
Copy Markdown
Contributor

OMG, if this fixes the 80% case, I ❤️ ❤️ you. 🎉

@as-cii

as-cii commented Oct 15, 2015

Copy link
Copy Markdown
Contributor Author

cjk

@benogle: 😂 👆 👆 👆 ❤️

I had to treat Korean characters differently, as their width isn't the same as japanese and chinese. I couldn't find a good name to express this in code (as opposed to double width and half width), so I simply named them koreanCharacters (I could have probably mentioned "Hangul" but as a non-native speaker it didn't feel super memorable).

Honestly I performed only super basic tests to check if this worked fine: probably a native speaker could give a more detailed feedback. I'll make sure to mention some of the people who actively participated in the CJK discussion if this looks good code-wise.

Thanks!

@saschanaz

Copy link
Copy Markdown

Korean characters use spaces but usually they don't wrap by words. For example:

아이돌마스터 신데렐라걸즈 스타라이트   |
스테이지

아이돌마스터 신데렐라걸즈 스타라이트 스| <- This is usually preferred
테이지

Web browser behavior example: https://twitter.com/newstapa/status/654793987543306241

@Zireael07

Copy link
Copy Markdown

<3 this is amazing for CJK users

@as-cii

as-cii commented Oct 16, 2015

Copy link
Copy Markdown
Contributor Author

@saschanaz: I wonder if, as a first step, it could be acceptable to wrap by words. How bad do you think that would be? The 🆒 thing about this approach is that it fits quite nicely our current code structure: it's far from being perfect, but it seems like it's way better than how we handle this scenario currently. What do you think? By the way, thanks for all the effort you have put into this. ❤️

@saschanaz

Copy link
Copy Markdown

@as-cii I think there can be some more progress but I agree that this is far better than current behavior. Great work 👍

@maxbrunsfeld

Copy link
Copy Markdown
Contributor

🚢

nathansobo pushed a commit that referenced this pull request Oct 16, 2015
@nathansobo
nathansobo merged commit 30f45d3 into master Oct 16, 2015
@nathansobo
nathansobo deleted the as-cjk-soft-wrap branch October 16, 2015 16:34
@nathansobo

Copy link
Copy Markdown
Contributor

Thanks @as-cii for your continued excellence.

@as-cii

as-cii commented Oct 16, 2015

Copy link
Copy Markdown
Contributor Author

❤️

@benogle

benogle commented Oct 16, 2015

Copy link
Copy Markdown
Contributor

I feel like this should close #1783 Thoughts?

@maxbrunsfeld

Copy link
Copy Markdown
Contributor

Yeah, I agree. We can create more specific issues for whatever remaining problems we find.

@kevinsawicki

Copy link
Copy Markdown
Contributor

so awesome 🎆

@ethanluoyc

Copy link
Copy Markdown

This is awesome

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants