UTF-8 support for word-wrap
-
Hello. I am currently working on a personal project to create a Japanese gamelist.xml that can be used in EmulationStation.
The problem is that EmulationStation only recognizes spaces as delimiters/line breaks, which makes natural word-wrapping of long sentences impossible for certain languages that basically do not use delimiters (such as Japanese and Chinese). This means that writing game descriptions becomes very difficult.
The RetroPie community in Japan (including Recalbox, etc.) calls this problem the "word wrap problem" and deals with it by either giving up on the description or inserting a space for each character.
To solve this problem, years or so ago, eagle0wl and zigurana edited Font.cpp on their forks.
https://github.com/eagle0wl/EmulationStation/blob/master/es-core/src/resources/Font.cppIt seemed to work well in the screenshot he uploaded to his blog. Could I ask you to implement a feature similar to this?
-
That could be an interesting challenge.
FWIW, the example from their blog (the 2nd picture) is somehow wrong.
While Japanese does not use spaces to separate the words in a sentence, there are some rules for line breaking in a multi-line text (Kinsoku Kinshori / 禁則処理). According to those rules, the 1st line in the picture should not start with a 「 (LEFT CORNER BRACKET). Am I wrong ? -
Thank you for your interest in my project.
Technically speaking, kinsoku shori is not a required implementation. While it is certainly important, it is just a rule to help you write "readable, understandable, and good-looking Japanese text".
In some cases, you can turn off "Apply line breaking rules to auto line breaks" and intentionally place them at the beginning/end of a sentence.
-
If this CJK fonts and wordwrap gets picked up at a later stage, just some notes:
Implications have been extensively discussed between Python developers, finally the change was dismissed, but a option to control the word wrap is planned for the
textwrap
module in v3.11 [2].[1] https://bugs.python.org/issue24665
[2] https://bugs.python.org/issue12499 -
@waitingmoon I've adapted the changes submitted by @Zigurana and eagle0wl and submitted a new PR, which was accepted recently.
If you're using RetroPie, you can install the
emulationstation-dev
package (from the experimental packages section) and try it out.
Contributions to the project are always appreciated, so if you would like to support us with a donation you can do so here.
Hosting provided by Mythic-Beasts. See the Hosting Information page for more information.