Fix unwanted CJK-Latin spacing in text decorations#7521
Fix unwanted CJK-Latin spacing in text decorations#7521Ri-Nai wants to merge 2 commits intotypst:mainfrom
Conversation
973b522 to
a9a8da1
Compare
I must admit that I'm concerned with the maintainability of the inline layouter. It has accumulated quite a bit of somewhat hacky code, in particular for CJK handling, which makes it quite hard to cleanly refactor (especially without good understanding of CJK languages since I can barely judge whether something is an improvement or a regression). |
|
Thanks for working on this, but I'll close it as I think this patch is too hacky and introduces too much maintainability burden. What it really shows me is that the CJK-Latin spacing should not be considered part of the glyph advance in the first place, but rather be handles as a separate spacing item or similar, that's inserted. |
Description:
Related to #7475 where underlines and highlights extend into the automatic spacing added between CJK and Latin characters.
Implementation Details:
Instead of modifying the underlying shaping logic (which inserts the spacing directly into glyph advances/offsets), this PR adjusts the decoration rendering in
deco.rs.It introduces
adjust_cjk_latin_spacingwhich heuristicsally detects if spacing was applied to the first/last glyphs of a run. It checks if the glyph is a CJK script and if the x-offset or advance includes the specific0.25empadding used by the shaper.It's just a temporary patch. While refactoring the CJK-Latin spacing implementation in the shaper might be the "pure" fix, it is a significant architectural change with high regression risks.