textmeasure: prevent Unicode markdown labels from clipping#2780
Open
ihopenre-eng wants to merge 1 commit into
Open
textmeasure: prevent Unicode markdown labels from clipping#2780ihopenre-eng wants to merge 1 commit into
ihopenre-eng wants to merge 1 commit into
Conversation
Signed-off-by: ihopenre-eng <247072151+ihopenre-eng@users.noreply.github.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.
Summary
docs/examplesas requestedRoot cause
The fixed text-measurement atlas does not include the em dash. It therefore measured the heading with the replacement glyph (672 font units) instead of the em dash (800 units). The generated font subset renders the real glyph, so the browser needed 1021.45 px while the
foreignObjectwas only 1018 px wide. The final word wrapped onto a second line and was clipped by the 51 px-high box.The updated Unicode path uses raw glyph advances from the original TTF whenever every rune is supported, while retaining the existing grapheme-width fallback for unsupported glyphs.
Verification
go test ./lib/textmeasure -count=1go vet ./lib/textmeasurego test ./d2graph -count=1go test ./d2lib -count=1go test ./d2renderers/d2svg -count=1go test ./e2etests -run 'TestE2E/stable/unicode_markdown_title$' -count=1foreignObject1022 x 51, content scroll size 1022 x 51go test -racewas unavailable because this environment hasCGO_ENABLED=0.Result
Fixes #2647