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

Arbitrary run breaks #191

Open
therahedwig opened this issue Jul 31, 2023 · 1 comment
Open

Arbitrary run breaks #191

therahedwig opened this issue Jul 31, 2023 · 1 comment

Comments

@therahedwig
Copy link
Contributor

In SVG there's a concept of a text chunk, sometimes referred to as an "Anchored Chunk", and is defined as follows:

An independent block of text in which all characters are positioned together. Each new absolute positioning adjustment (due to an ‘x’ or ‘y’ attribute, or forced line break) creates a new text chunk. Ligature substitution and bidi-reordering only occur within a text chunk. Text chunks are only relevant to pre-formatted text.

In a way, these are not too dissimilar to the concept of 'lines'. However, where lines imply the presence of a hard break inside the text, this one can also be invoked by setting certain rich text properties (the x and y properties). Because Firefox has some issues here as well (in particular it doesn't handle the bidi case), I had hoped to delay this particular feature, until we ran into a situation where the font Calibri decided to make ligatures between 't' and 'i', which lead to problems with text positioning.

Right now I have a simple implementation that adds raqm_set_arbitrary_run_break, which in turn toggles a boolean in the text_info struct. Said boolean is checked by _raqm_compare_text_info, breaking the run when the second info has this toggled.

This works for non-required ligatures. It doesn't work for required ones (probably because in _raqm_shape Harfbuzz gets the full text and has no concept of these arbitrary breaks). Furthermore, it of course doesn't split the bidi runs.

Splitting the bidi runs seems like it requires reworking both instances of _raqm_bidi_itemize to apply to partial pieces of text (I'm having a hard time figuring out what that would look like as I'm not very good at C). Then in _raqm_itemize the text would be split up on the basis of whether an arbitrary run break is present.

Such rework will be necessary for horizontal-in-vertical as well, because while I'm having a hard time interpreting UAX 9 and UAX 50's interaction with one another, my best guess is that you only want to apply the bidi-algorithm to the horizontally shaped parts and ignore the vertically shaped parts.

My problem right now is that I am not really sure how to proceed here.

FWIW, I am very hesitant to insert unicode format controls inside the text-string to trick Raqm into giving correct results, because computing SVG's x and y positioning needs to happen after the CSS white-space rule, and I'm worried I'm going to lose track of which index in the final string corresponds to the input string index if I start inserting characters that late into the text layout algorithm.

@dimula73
Copy link

dimula73 commented Aug 8, 2023

Just for your information, here is Krita we carry a custom patch for this feature:

https://invent.kde.org/graphics/krita/-/merge_requests/1867

Do you think it is good enough to be proposed upstream to libraqm?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants