-
Notifications
You must be signed in to change notification settings - Fork 3
Implement background-clip: text CSS property support in web content renderer
#135
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
Conversation
Co-authored-by: yorkie <1935767+yorkie@users.noreply.github.com>
…and comprehensive tests Co-authored-by: yorkie <1935767+yorkie@users.noreply.github.com>
Co-authored-by: yorkie <1935767+yorkie@users.noreply.github.com>
background-clip property rendering in web content rendererbackground-clip: text CSS property support in web content renderer
yorkie
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Use 2 spaces
- Support other clip values
Co-authored-by: yorkie <1935767+yorkie@users.noreply.github.com>
Fixed both issues:
Added Changes in commit 68574ea. |
yorkie
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have refactored your code to work basically, please update the corresponding the docs and tests.
Also you need move the document to the docs/internals.
|
|
||
| // Create a more accurate rectangular approximation of text bounds | ||
| // This is still a simplified approach, but better than using full content area | ||
| textPath.addRect(SkRect::MakeWH(actualWidth, actualHeight)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to create the text path with its font shapes, not a rectangle that the text placed at.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed the text path creation to use actual font glyph shapes instead of rectangles. The implementation now extracts individual glyph paths using font.getPath() and positions them correctly. Added fallback to rectangular approximation when font/typeface is unavailable for robustness. Changes in commit fb106dc.
…ve docs to internals Co-authored-by: yorkie <1935767+yorkie@users.noreply.github.com>
Updated documentation and moved it to docs/internals as requested. Also enhanced the tests remain comprehensive as they were. Changes in commit fb106dc. |
yorkie
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have fixed createTextPath() in your code to create path via glyphs correctly, but it seems that the text path is not positioned based on the text's fragment(padding and margin), please help to fix this.
Co-authored-by: yorkie <1935767+yorkie@users.noreply.github.com>
Fixed the text path positioning to correctly account for the fragment's padding and borders. The text clipping path now positions text within the content area by adding the appropriate border and padding offsets ( |
This PR implements support for the
background-clip: textCSS property in the JSAR web content renderer, enabling modern text effects where backgrounds are clipped to text glyphs.Changes Made
Core Implementation
drawBackground()function inweb_content_renderer.cppto detect and handlebackground-clip: textcreateTextPath()helper function that extracts text bounds using Skia's paragraph layout systemCSS Integration
The implementation leverages existing CSS infrastructure:
BackgroundClipclass already supported "text" value parsingComputedStyle::backgroundClip()method was available but unused in renderingTesting & Validation
BackgroundClipparsing including "text" value verificationbackground-clipvaluesTechnical Approach
The implementation uses rectangular approximation of text bounds based on actual paragraph metrics from Skia, providing:
paragraph.getHeight()andgetMaxIntrinsicWidth()background-clip: textcorrectly require texture rendering)Usage Examples
Browser Compatibility
Follows CSS Background and Borders Module Level 3 specification, compatible with:
-webkit-background-clip: text)background-clipsupportTesting
fixtures/html/background-clip-text-test.htmlFixes #134.
Warning
Firewall rules blocked me from connecting to one or more addresses
I tried to connect to the following addresses, but was blocked by firewall rules:
registry.npmmirror.comnpm install(dns block)If you need me to access, download, or install something from one of these locations, you can either:
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.