fix(render、pdf): respect color alpha channel#105
Conversation
feat(renderer): refactor color painting logic into a separate function test: add tests for rendering with transparent backgrounds and color alpha test: update test cases to include new color formats
Deploying ratex with
|
| Latest commit: |
6bf1d6c
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://87580c7b.ratex.pages.dev |
| Branch Preview URL: | https://fix-alphacolor.ratex.pages.dev |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fbfbbb2d5e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| // CID as 2-byte big-endian. | ||
| let cid_bytes = [(new_cid >> 8) as u8, (new_cid & 0xFF) as u8]; | ||
|
|
||
| let alpha_applied = apply_non_stroking_alpha(content, color, alpha_states); |
There was a problem hiding this comment.
Apply alpha to raster emoji glyphs in PDFs
When a transparent \textcolor wraps a color emoji and collect_glyph_usage chooses an emoji raster, emit_glyph returns through the XObject branch before this new graphics-state application runs, so the PDF resource records the alpha but the emoji Do operation is emitted at full opacity. Wrap the emit_emoji_raster path with the same ExtGState save/restore so cases like \textcolor{#00000000}{🙂} do not render an opaque emoji.
Useful? React with 👍 / 👎.
| @@ -561,13 +572,7 @@ fn render_glyph_with_font( | |||
| } | |||
There was a problem hiding this comment.
Apply alpha to PNG raster emoji glyphs
This alpha-aware paint is only used after a glyph reaches render_glyph_with_font; on platforms with PNG emoji strikes, render_glyph/try_emoji_vector_then_bitmap return from try_blit_emoji_raster_fallback first, and that draw_pixmap uses default PixmapPaint opacity. As a result, transparent or semi-transparent \textcolor still produces opaque raster emoji in PNG output; pass the color alpha into the raster blit path as well.
Useful? React with 👍 / 👎.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d08e0280c3
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| } | ||
|
|
||
| if fill { | ||
| let alpha_applied = apply_non_stroking_alpha(content, color, alpha_states); |
There was a problem hiding this comment.
Apply alpha before constructing PDF paths
For any transparent DisplayItem::Path, this inserts q/gs after the m/l/c path construction operators and before the f/S painting operator. PDF path objects may only be completed by a painting operator (optionally after clipping), so strict renderers/preflight tools can treat these transparent filled or stroked paths as invalid/undefined; set the ExtGState before starting the path (as rects/lines do) or avoid wrapping the path mid-construction.
Useful? React with 👍 / 👎.
|
@codex review |
|
Codex Review: Didn't find any major issues. 👍 ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
close #103 #104