fix(layout): strip default-ignorable characters instead of rendering fallback glyphs - #3456
Closed
hendrikmolder wants to merge 1 commit into
Closed
Conversation
🦋 Changeset detectedLatest commit: 1a480bb The changes in this PR will be included in the next version bump. This PR includes changesets to release 7 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
…fallback glyphs Bidi controls and other Unicode Default_Ignorable_Code_Points (e.g. U+202A LRE, U+202C PDF, U+200F RLM, zero-width chars, BOM) were not in the small IGNORABLE_CODEPOINTS list, so they reached glyph mapping, missed the font's cmap and were drawn as fallback .notdef glyphs (visible garbage, often overprinted on an adjacent letter). Strip characters the font cannot render using the Unicode default-ignorable set (mirroring fontkit's isDefaultIgnorable), while preserving the previously handled U+2028/U+2029 separators. Characters the font does provide a glyph for are left untouched.
hendrikmolder
force-pushed
the
fix/strip-default-ignorable-bidi-controls
branch
from
July 22, 2026 11:44
cae17be to
1a480bb
Compare
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 rendering of Unicode Default_Ignorable_Code_Points (bidi controls, zero-width chars, BOM, variation selectors, …) which currently show up as visible fallback
.notdefglyphs in generated PDFs.Problem
Characters like
U+202A(LRE),U+202C(PDF),U+200F(RLM), zero-width spaces/joiners, and the BOM are default-ignorable — browsers render nothing for them. In react-pdf they appear as garbage, typically a stray glyph overprinted on the first letter of the following text (plus a swallowed adjacent space).This is common with text (e.g. names) for RTL locales, which often arrive wrapped in bidi embedding controls. Example:
"\u202aExample Name\u202c\u200f"renders with a stray glyph stacked on the first letter.Root cause
packages/layout/src/text/ignoreChars.tsonly stripped a 3-entry list (U+2028,U+2029,U+2060). All other default-ignorables reached font substitution, missed the font cmap, and were drawn as fallback glyphs. fontkit already handles these correctly viaisDefaultIgnorable/hideDefaultIgnorables, but that path is not reached because react-pdf performs its own per-codepoint font substitution first.Changes
isDefaultIgnorableranges.U+2028/U+2029separator stripping (kept via an explicit extra set) to avoid a regression.packages/layout/tests/text/ignoreChars.test.tsand a changeset.Testing
yarn vitest run packages/layout— all 417 layout tests pass (incl. 6 new). Lint + typecheck clean.