Skip to content

Fix Excel theme tint color matching - #360

Open
developer0hye wants to merge 1 commit into
MathNya:masterfrom
developer0hye:fix/excel-theme-tint
Open

Fix Excel theme tint color matching#360
developer0hye wants to merge 1 commit into
MathNya:masterfrom
developer0hye:fix/excel-theme-tint

Conversation

@developer0hye

Copy link
Copy Markdown
Contributor

Problem

calc_tint converts theme colors through a floating-point 255-step HLS space. Excel-compatible exports use the 240-step integer HLS model, so several theme tints resolve one or more RGB levels away from native output. For example, DAB6BA at tint 0.7999 resolves to F8F0F1 instead of F8EFF0.

Excel-compatible workbooks also encode common whole-percent tints as nearby signed-short values such as 0.79998168889431442. Treating those values literally can move the resulting color another level.

Fix

  • convert theme tints through the 240-step integer HLS space
  • preserve the integer rounding stages and truncate the tint-adjusted luminance before converting back to RGB
  • recover near-whole-percent tint values only within one signed-short step while preserving arbitrary values such as 0.7999
  • update the existing issue 184 fixture expectations to colors measured from a current native Excel PDF export
  • add regression coverage for native tint samples, encoded percentages, the normalization threshold, and luminance truncation

Testing

  • cargo +nightly fmt --all --check
  • cargo clippy -- -D warnings
  • cargo test (116 unit, 113 integration + 2 ignored, 4 streaming + 1 ignored, 79 doc + 20 ignored)

Related: #184
Related: developer0hye/office2pdf#1394

Signed-off-by: Yonghye Kwon <developer.0hye@gmail.com>
@developer0hye

Copy link
Copy Markdown
Contributor Author

CI note: the formatting job passed. The Rust 1.88 job stops during fresh dependency resolution, before this PR's code is compiled:

Adding aes v0.9.3 (requires Rust 1.89)
error: rustc 1.88.0 is not supported by aes@0.9.3

This PR does not change Cargo.toml or dependency constraints. The remaining build matrix entries were cancelled by fail-fast after the 1.88 job failed. At head 727fe9d4, cargo fmt --check, cargo clippy -- -D warnings, and the full local test suite pass (116 unit, 113 integration with 2 ignored, 4 streaming with 1 ignored, and 79 doctests with 20 ignored).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant