dotnet / wpf

WPF is a .NET Core UI framework for building Windows desktop applications.
MIT License
7.1k stars 1.17k forks source link

Support ruby characters #7595

Open rampaa opened 1 year ago

rampaa commented 1 year ago

Some languages, such as Japanese, use ruby characters for various reasons. I'd really appreciate it if WPF let us display such characters with controls like TextBlock/TextBox/RichTextBox.

miloush commented 1 year ago

I understand the need for displaying phonetic guide in documents, but I am wondering if you can suggest some use case for a TextBlock/user interface to be utilizing it? You also mention displaying characters, but the ask for text box - do you expect users to be able to type them as well?

rampaa commented 1 year ago

I am wondering if you can suggest some use case for a TextBlock/user interface to be utilizing it

Sure, we'd need this for an e-book reader with proper furigana support. Or for a Japanese popup dictionary app (I've actually developed one such program in WPF, see https://github.com/rampaa/JL if you are interested), being able to display ruby characters would allow us to create something like:

.

but the ask for text box - do you expect users to be able to type them as well

No, not really. I've suggested TextBox to support them as well because TextBlocks don't support some functionality the TextBoxes/RichTextBoxes offer and in those cases we are forced to use TextBox/RichTextBox instead of TexBlocks. For example, in the aforementioned program I've developed, I am forced to extensively use TextBoxes instead of TextBlocks because I need to get the index of a character from the cursor position and I can easily do that with a TextBox via the GetCharacterIndexFromPoint method, same cannot be done with a TextBlock to the best of my knowledge.

lindexi commented 1 year ago

The ruby characters needs the support of typesetting layout. Not just display technology. And the typesetting rules of ruby in different languages and cultures are different.

image

The ruby will change the line height. This means that it will be better if there is support for the typesetting engine.

miloush commented 1 year ago

Technically for horizontal text, and probably easier for the dictionary case rather than the e-book case, I don't see why one wouldn't be able to implement ruby themselves using the current API.

rampaa commented 1 year ago

I don't see why one wouldn't be able to implement ruby themselves using the current API.

I know that I can emulate a piss-poor ruby support but that's useless for my projects. Maybe one can do a better job with the current API but I simply have no idea how that can be done (would appreciate a concrete example).

Regardless of whether it's theoretically possible to roll out our own ruby implementation without a new API, I think it would be tremendously better if WPF had ruby support baked in.

luojunyuan commented 1 year ago

I really need this too. The Textblock with ruby characters would cause performance issue. Imaging you have an article to ruby all the words. The combine of StackPanel and Textblock may make text render very slowly.