markdown: Apply heading level text styles to the shaped text - #63465
Open
archcorsair wants to merge 1 commit into
Open
markdown: Apply heading level text styles to the shaped text#63465archcorsair wants to merge 1 commit into
archcorsair wants to merge 1 commit into
Conversation
The preview declares a semibold weight and a muted h6 color in heading_level_styles, but apply_heading_style only wrote them onto the heading div. Text runs are shaped from the builder's style stack, which never saw the per-level style, so headings rendered at the base weight and color. Push the level style onto the stack as well; the div keeps driving font size and line height for layout.
5 tasks
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.
Objective
Follow-up to #63118. That PR set the preview's headings to semibold and gave h6 a muted color through
heading_level_styles, and the PR body says as much, but neither actually rendered. Headings in the preview came out at the base weight and color, which you can see in the after screenshot on that PR: every heading is regular while the bold body text and the table header cells are heavy.I found this while looking into @Arcitec's report on #63118 about bold not rendering with SF Pro. That one turned out to be a different bug: SF Pro is a variable font, and the Linux text system does not pass the requested weight through to it. It is tracked in #60155 and #62832 has a fix up for it, so this PR does not touch it.
Solution
apply_heading_stylewrote the per-level style onto the heading div only. The div's text style reaches layout, which is why the font sizes worked, but the text runs are shaped fromMarkdownElementBuilder's style stack, and nothing ever pushed the level style onto that stack. So weight and color were dropped on the floor.The fix pulls the level lookup out into
heading_level_styleand haspush_markdown_headingrefine the heading's run text style with it before pushing, alongside the existing div refinement. No style values change anywhere. The agent panel's level styles only set font size, so its rendering is identical before and after; I checked.Testing
cargo test -p markdownand./script/clippyare clean.FontIdfor every font, so an assertion on run weight could not fail.Self-Review Checklist:
Showcase
Before is
mainat 399258f, which already includes #63118, so the only difference is the heading weight and the h6 color.Release Notes: