Preserve cursive shaping under letter spacing - #713
Closed
waywardmonkeys wants to merge 2 commits into
Closed
Conversation
Layout policy needs to distinguish scripts whose letters participate in cursive joining without treating every `Join_Causing` character as evidence of a cursive script. In particular, U+200D ZERO WIDTH JOINER has `Joining_Type=Join_Causing` and can occur in Latin or emoji text. Pack `Joining_Type` into `parley_data::Properties`, and generate a sorted lookup of ISO 15924 tags for scripts containing `Left_Joining`, `Right_Joining`, or `Dual_Joining` characters. Excluding `Join_Causing` and `Transparent` keeps `Zyyy` from being classified solely because it owns ZWJ and inherited marks. Expose `script_has_joining_characters` in `parley_engine` for its `parlance::Script` vocabulary, and retain the resolved `script` in each `ShapedRun`. `Item` and `ShapedRun` derive their convenience accessor from that script instead of caching duplicate state, so public record construction remains straightforward and there is no script/classification invariant to maintain. The lookup deliberately reports a Unicode fact. It does not inspect a particular string or decide letter-spacing policy.
CSS Text requires user agents that cannot perform cursive elongation to avoid inserting gaps between a cursive script’s typographic letter units. Such text is effectively treated as one tracking unit per word, while spacing can still apply to non-cursive content such as spaces. Parley instead added `letter_spacing` to every shaped cluster, which broke Arabic and other cursive connections. Use the resolved-script fact retained by `ShapedRun` to suppress letter spacing for non-space clusters in scripts with joining characters. Spaces still receive both `letter_spacing` and `word_spacing`, and non-cursive runs remain tracked normally. Because the decision uses the resolved script rather than the presence of a `Join_Causing` character, a Latin run containing U+200D ZERO WIDTH JOINER remains trackable. CSS Text and CSS Fonts also specify that non-default letter spacing disables optional ligatures, while low-level `font-feature-settings` take precedence. Add default `liga=0` and `clig=0` shaping features only when tracking is actually applied and the author did not supply those tags. Required and cursive shaping features remain untouched. References: - CSS Text Level 3, Tracking and Cursive Scripts: https://www.w3.org/TR/css-text-3/#cursive-spacing - CSS Fonts Level 4, Feature and variation precedence: https://www.w3.org/TR/css-fonts-4/#feature-variation-precedence Add coverage for default and explicitly authored ligatures, cursive words and spaces, and Latin text containing ZWJ. Extend `parley_bench` with nonzero-letter-spacing cases so this path remains measurable. Final Tango comparisons against the parent commit were flat within run-to-run noise for tracked Arabic (+0.03% and -0.64%) and Latin (+0.44% and -0.97%). Tracked Japanese measured +2.79% and +4.19% because shaping now processes the two required optional-ligature overrides; the zero-spacing suite showed no stable regression across repeated runs.
Contributor
Author
Contributor
Author
|
This causes problems for Tom, so I will not pursue this. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
CSS Text requires user agents that cannot perform cursive elongation to avoid inserting gaps between a cursive script’s typographic letter units. Such text is effectively treated as one tracking unit per word, while spacing can still apply to non-cursive content such as spaces. Parley instead added
letter_spacingto every shaped cluster, which broke Arabic and other cursive connections.Use the resolved-script fact retained by
ShapedRunto suppress letter spacing for non-space clusters in scripts with joining characters. Spaces still receive bothletter_spacingandword_spacing, and non-cursive runs remain tracked normally. Because the decision uses the resolved script rather than the presence of aJoin_Causingcharacter, a Latin run containing U+200D ZERO WIDTH JOINER remains trackable.CSS Text and CSS Fonts also specify that non-default letter spacing disables optional ligatures, while low-level
font-feature-settingstake precedence. Add defaultliga=0andclig=0shaping features only when tracking is actually applied and the author did not supply those tags. Required and cursive shaping features remain untouched.References:
Add coverage for default and explicitly authored ligatures, cursive words and spaces, and Latin text containing ZWJ. Extend
parley_benchwith nonzero-letter-spacing cases so this path remains measurable.Final Tango comparisons against the parent commit were flat within run-to-run noise for tracked Arabic (+0.03% and -0.64%) and Latin (+0.44% and -0.97%). Tracked Japanese measured +2.79% and +4.19% because shaping now processes the two required optional-ligature overrides; the zero-spacing suite showed no stable regression across repeated runs.