Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Check script of combining marks during font fallback #6857

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

Merged
merged 1 commit into from
Oct 26, 2022

Conversation

miloush
Copy link
Contributor

@miloush miloush commented Jul 30, 2022

Fixes #6801

Description

Font fallback does not check combining marks associated with a base character, because the shaping engine might precompose the character with mark into single one which might be present in the font.

However, when the marks are from a different script than the base character, the text does not get to the correct shaping engine, and inappropriate clusters are made (e.g. punctuation with Indic vowels).

The PR compares the script of the base character and the combining marks and only allows to skip font fallback check if they are the same, using the existing character classification tables.

Customer Impact

Customers not taking this fix will see incorrectly shaped text and will have difficulty editing affected text, since in non-Latin script cases, cursor cannot be put between the base character and the combining mark.

Visual Studio is a notable impacted customer as in general programming languages are more susceptible to placing isolated combining marks inside quotation marks as chars and strings, and those get glued together. Depending on how the editor colorizes and tokenizes the string, customers will see inconsistent rendering that might cause a reflow just as cursor is moved around.

Regression

No.

Testing

Built and verified the test case in #6801 is shaped as expected in 7.0.0-preview.4.22229.4, i.e. Indic vowel marks don't get shaped together with punctuation as base characters, and that the specified font for fallback is selected. Ad-hoc verified that Latin combining marks still work with Latin bases like before.

Risk

Runs with marks from different scripts will get split iff the marks are not present in the font. This could theoretically affect some combinations valid via script extensions, however, neither DWrite nor WPF currently support script extensions.

There will be slight performance decrease for combining mark characters (two more lookups of character attributes). This is a trade off decision that allows base characters (including standard Latin text going through fast path) to remain unaffected.

The existing code looks up attributes several times per each character. That is an opportunity for potentially interesting performance improvement, however this PR does not address it.

Microsoft Reviewers: Open in CodeFlow

@miloush miloush requested a review from a team as a code owner July 30, 2022 10:22
@ghost ghost assigned miloush Jul 30, 2022
@ghost ghost added the PR metadata: Label to tag PRs, to facilitate with triage label Jul 30, 2022
@ghost ghost requested review from dipeshmsft, singhashish-wpf and SamBent July 30, 2022 10:22
@ghost ghost added the Community Contribution A label for all community Contributions label Jul 30, 2022
@dipeshmsft dipeshmsft merged commit 1918a81 into dotnet:main Oct 26, 2022
@dipeshmsft
Copy link
Member

@miloush thanks for your contributions.

@miloush miloush deleted the FontFallbackMarks branch November 1, 2022 01:54
singhashish-wpf pushed a commit that referenced this pull request Nov 1, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Dec 1, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Community Contribution A label for all community Contributions PR metadata: Label to tag PRs, to facilitate with triage
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Characters with different font after fallback shaped together
3 participants