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

Japanese word wrapping is weird #1497

Closed
bigfarts opened this issue Apr 15, 2022 · 3 comments · Fixed by #1498
Closed

Japanese word wrapping is weird #1497

bigfarts opened this issue Apr 15, 2022 · 3 comments · Fixed by #1498
Labels
bug Something is broken

Comments

@bigfarts
Copy link
Contributor

bigfarts commented Apr 15, 2022

Describe the bug
Japanese text wraps at weird points of sentences.

image

To Reproduce
Display the following text in egui:

ゲームを下記より選択してください。

リストが空の場合は、「roms」ディレクトリにROMファイルを、「saves」ディレクトリにセーブファイルを配置してください。

Expected behavior
Wrapping that looks more like this:

ゲームを下記より選択してください。

リストが空の場合は、「roms」ディレクトリにROMファイル
を、「saves」ディレクトリにセーブファイルを配置してくだ
さい。

Screenshots
See above.

Desktop (please complete the following information):

  • OS: macOS
  • Browser N/A
  • Version 0.17.0
@bigfarts bigfarts added the bug Something is broken label Apr 15, 2022
@emilk
Copy link
Owner

emilk commented Apr 15, 2022

If you want to make a PR to fix this, take a look at https://github.com/emilk/egui/blob/master/epaint/src/text/text_layout.rs#L710-L768

@bigfarts
Copy link
Contributor Author

Thanks! Is there a way to do lookahead? There are some characters that are only allowed to have a line break after them depending on the subsequent character e.g. it's permissible to break between しろ but not between しゅ

@emilk
Copy link
Owner

emilk commented Apr 15, 2022

Of course there is a way; it will just require more code :)

emilk pushed a commit that referenced this issue Apr 16, 2022
This allows line breaks after any kana, unless they are immediately followed by a gyōtō kinsoku character, in which case the line may not break at that point.

Also pedantically renamed is_chinese to is_cjk_ideograph as is_chinese will also cause line breaks on Japanese kanji.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something is broken
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants