Handle line heights changing within atoms - #864
Conversation
3032289 to
3e7861f
Compare
| for character in characters.iter().skip(1) { | ||
| self.add_style(character.style_index, &data.style_metrics, contributed); | ||
| } |
There was a problem hiding this comment.
Nit: this could probably skip consecutive chars with the same style?
There was a problem hiding this comment.
It could, but I'm not sure it would save a lot except for very pathological cases. The add_style call already does a scan to check if the style has been added previously. So then, three things have to line up for this to matter: a lot of atoms with more than one character, actually having styles crossing a grapheme or a ligature across styles, and having a lot of styles.
What might be useful is to check per-atom whether it has mixed styles, but the version I tried which did that during line breaking regresses it by 4%.
There was a problem hiding this comment.
I ended up adding a harmless-enough guard that should catch most of those pathological cases, by checking whether the style is different from the atom's first style.
| self.add_style(character.style_index, &data.style_metrics, contributed); | ||
| } | ||
| // Take this path for the run's next atom too, which could also have mixed styles. | ||
| self.last_text = (usize::MAX, 0); |
There was a problem hiding this comment.
Could we document the use of sentinel values here?
There was a problem hiding this comment.
Good point; I've instead simplified it a bit, by checking RunData::has_mixed_style_atoms directly. (There's one remaining use of (usize::MAX, 0) not introduced by this PR, in the Default impl, but I think that one is clear enough as-is.)
3e7861f to
ed7f002
Compare
LLM Contributions: Investigation, initial implementation, review.
On top of #863. If the line height changes within an atom, we add the spans of all the atom's characters to the line. I believe this matches Blink; but note we do still diverge a bit from Blink regarding the "strut" and accounting styles per-character instead of per-span.
Supercedes #761, #828, #839.
Without this change, the test renders as follows.
Performance
Together with #863, this benches as follows (but there may be some placement noise again).
Changelog