Repository navigation
Conversation
laurmaedje
left a comment
There was a problem hiding this comment.
Thanks for the PR. I'm not sure I understand exactly how you arrived at this condition.
Overall, doing something like this is probably fine, but it's more of a band-aid fix as there are more tag-related issue in inline layout. In the medium term a more robust solution for tag handling across all of inline layout will be necessary.
| /// Access the first glyph with non-zero advance in the line. | ||
| pub fn leading_glyph(&self) -> Option<(&ShapedText<'a>, &ShapedGlyph)> { | ||
| for (_, item) in self.0.iter() { | ||
| let Item::Text(text) = &**item else { continue }; |
There was a problem hiding this comment.
This will skip over non-tag non-text items, which shouldn't be the case.
| if let Some(glyph) = text | ||
| .glyphs | ||
| .iter() | ||
| .find(|glyph| glyph.x_advance.at(glyph.size) > Abs::zero()) |
There was a problem hiding this comment.
Why exactly zero-width glyphs. Could you elaborate on this condition?
|
Thanks for looking! This change is scoped specifically to the regression where labels insert a zero-advance glyph between the word and the punctuation, causing the overhang logic to "miss" the comma. To verify exactly what was happening in the renderer, I added some temporary debug printing to inspect the frame structure for the example. #set par(justify: true)
Regular:
#block(stroke: 0.5pt + blue, width: 4cm)[This is a text with just, the right length.]
Label the word:
#block(stroke: 0.5pt + blue, width: 4cm)[This is a text with just,<label> the right length.]Without a label, we get two clean text nodes: With a That lone space glyph (the The new helper skips such glyphs to find the comma again. I agree that longer-term we need a broader tag story, but this unblocks the overhang regression without touching other inline layout code.
I’ve tightened both helpers so they now
This is directly related to the frame structure I described in the general comment. The "zero-width glyphs" here are precisely those artifacts (like the collapsed space glyph in Since |
|
Any particular reason why you closed your PR? |
It's been a few months with no activity, and I unfortunately no longer have the time to maintain or update this PR. I also felt the implementation might still need some work. I decided to close it for now, but anyone is welcome to continue where I left off." |
related to #7219