Thanks!

My angle is mostly based on my project of a text editor which is designed for working on RTL-heavy typesetting source files; think something similar to LaTeX, where you could have line of RTL text, in the middle of it an invocation of a function with an English name, and in its' parameter list you would have more RTL text. Something like "TEXT \foo{ARG} MORE TEXT" (with the usual UAX #9 convention of having upper case characters represent RTL and lower case represent LTR).

With the BiDi algorithm as-written the directionality of the text leaks out to the weak and natural direction syntax tokens and messes them up. I fully know about explicit format control character as the way to counter that, and the editor can make it easier for users to enter the correct ones. The patch I was already able to land into Qt 6.9 helps a lot with this. However, the ease of use can be significantly improved, because the editor has semantic information about the meaning of the code and could resolve directionality of weak and neutral characters based on that information. So the user doesn't has to fiddle with adding and removing the control characters as they edit the source - this can be quite compelling UX.

As the _only_ leverage Scribe gives to modify the visual appearance of text without interfering with the QTextDocument internal buffers (and more importantly - undo stack) is the extra character formats in QTextLayout, I was exploring use of that avenue.  Seeing that LayoutDirection is documented as also a character format property led me thinking that this could be an opening.

However I acknowledge this is probably very niche use case, so if this designation was never intended there is no need to further push the point.

Best,
Igor

On 03/11/2024 12:37, Volker Hilsheimer wrote:

On 31 Oct 2024, at 14:51, Igor Khanin <i...@khanin.biz> wrote:

Greetings,

I hope this is the right place to post this. I'm looking for advice as well as 
any historical context I can get.

The documentation states that the `QTextFormat::LayoutDirection` text format 
property is both a paragraph and a character property. When set on a block 
format, it indeed affects the block's base direction via 
`QTextBlock::textDirection`. However when set on a character format, to the 
best of my understanding it appears to have no effect whatsoever. I'd expect it 
to have some sort of similar impact on the BiDi algorithm - perhaps overriding 
the directional character type of the character to be L or R, or maybe making a 
sequence of characters with the same property value behave as if they were an 
isolation run, or some such. But that can't obviously happen currently, as 
`QBidiAlgorithm` has no access to any formats and finishes its' work before 
character formats are resolved anyway.

This appears to be the case since Scribe was first released back in Qt 4, or at 
the very least predates the current Git history. So my question is why then the 
documentation says that? Was there an intention to implement some behavior that 
then never happened?

Furthermore - would it make sense for this property to start _actually_ doing 
anything on individual characters? I have a hacky POC, but don't want to waste 
my own and other's time if this is something that would be considered too niche 
or disruptive.

Best,
Igor
Hi Igor,

It’s the right place to post this, but it would help to understand what you are 
trying to achieve with an implementation of layout direction on as a character 
format. My understanding of the subject doesn't go very deep (and I can’t say 
if the documentation is wrong or simply misleading - perhaps it’s a read-only 
attribute), but to change layout direction within a block, you’d usually insert 
Unicode control characters into your text.

Volker


--
Development mailing list
Development@qt-project.org
https://lists.qt-project.org/listinfo/development

Reply via email to