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

Handle inline boxes in cluster geometry and path #203

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

tomcur
Copy link
Member

@tomcur tomcur commented Dec 6, 2024

Inline boxes are currently silently ignored in some places, making text selection wrong when they are used, as their advance is not used in offset calculation and the run indices are counted wrong as the boxes are skipped.

To see the issues currently present, insert the following in PlainEditor::update_layout and run vello_editor.

builder.push_inline_box(crate::InlineBox {
    id: 0,
    index: 7,
    width: 50.0,
    height: 50.0,
});

This PR fixes the issues I've found, though the cursor position when the cursor has a downstream affinity at the byte index of an inline box is still wrong, I believe. For example, in "AB" with an inline box between "A" and "B", when the cursor is between the two characters with downstream affinity, it shows up on the right side of the A, whereas it would be expected to show up at the left side of the B.

Inline boxes are currently silently ignored in some places, making text
selection wrong when they are used, as their advance is not used in
offset calculation and the run indices are counted wrong as the boxes
are skipped.

To see the issues currently present, insert the following in
`PlainEditor::update_layout` and run vello_editor.

```rust
builder.push_inline_box(crate::InlineBox {
    id: 0,
    index: 7,
    width: 50.0,
    height: 50.0,
});
```

This PR fixes the issues I've found, though the cursor position when the
cursor has a downstream affinity right on an inline box is still wrong,
I believe. For example, in "AB" with an inline box between "A" and "B",
when the cursor is between the two characters with downstream affinity,
still shows up on the right edge of the A.
for (run_index, run) in line.runs().enumerate() {
for run_index in 0..line.len() {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately we can't just use line.items(), as GlyphRunIter currently appears to skip the run on empty lines.

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

Successfully merging this pull request may close these issues.

1 participant