[Development] QTextFormat::LayoutDirection as a character format property?
Lars Knoll
lars at knoll.priv.no
Mon Nov 4 09:48:14 CET 2024
Hi,
> On 3 Nov 2024, at 11:37, Volker Hilsheimer via Development <development at qt-project.org> wrote:
>
>> On 31 Oct 2024, at 14:51, Igor Khanin <igor at 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.
LayoutDirection is a property that is only relevant for blocks and is basically the same as the HTML 'dir' property for a <div> and simply changes the embedding level of the paragraph.
>> 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.
If you want to affect layout within a block, please just use the correct Unicode control characters (LRE/RLE/PDF etc). Those should give you all the control you need within a block.
>>
>> 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?
I don’t see where the docs state that QTextFormat::LayoutDirection are affecting character formats. If it does, it’s a bug in the documentation.
>>
>> 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.
I don’t really see the benefit of doing this. It complicates a whole lot of things, both in the layout engine, and when exporting to HTML. There should not be anything there that you can’t simply achieve in more compliant way using Unicode control characters.
Cheers,
Lars
>>
>> 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 at qt-project.org
> https://lists.qt-project.org/listinfo/development
More information about the Development
mailing list