fix(text): render Devanagari and other complex scripts correctly#8895
Open
willeastcott wants to merge 1 commit into
Open
fix(text): render Devanagari and other complex scripts correctly#8895willeastcott wants to merge 1 commit into
willeastcott wants to merge 1 commit into
Conversation
getSymbols now keeps a base character together with its trailing combining marks, ZWJ/ZWNJ joiners and virama-joined consonants as a single grapheme cluster. This lets CanvasFont shape whole syllables via the browser's text shaper, instead of laying out each code point as a separate glyph. Fonts with per-code-point atlases (bitmap/MSDF) expand any missing cluster back to its code points, so they render as before. Fixes #4102 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Fixes #4102.
string.getSymbolssplit Devanagari into one symbol per code point, so vowel signs (matras) detached from their consonant and conjuncts never formed — text rendered garbled and out of order as reported.getSymbolsnow forms proper grapheme clusters: a base character plus its trailing combining marks (\p{M}),ZWJ/ZWNJjoiners and virama-joined consonants. BecauseCanvasFontrasterizes each symbol with the browser's text shaper, whole syllables now shape into a single correctly-composed glyph (Devanagari, plus Arabic, Tamil, etc.).Bitmap/MSDF fonts have per-code-point atlases that don't contain a multi-code-point cluster, so
TextElementexpands any font-missing cluster back into its code points — they render exactly as before.Tested: added
getSymbolsunit tests for Devanagari vowel signs and conjuncts; existing emoji/flag/ZWJ cases are unchanged; verified end-to-end that a realCanvasFontatlas now contains correctly-shaped Hindi clusters.🤖 Generated with Claude Code