Fix incorrect lineJoin and pathfactor in get_drawings()#4955
Conversation
|
All contributors have signed the CLA ✍️ ✅ |
|
I have read the CLA Document and I hereby sign the CLA |
|
Many thanks for updating things. Could your squash your 4 commits into 1 commit and rebase on top of current main? Then i think i'd be ok to merge this PR, after checking with @JorjMcKie. |
3cf53a9 to
659e86b
Compare
|
Thanks for the review. |
|
I checked the CI failure more carefully. The determinant-based I'll change it to: float sx = sqrtf(ctm.a * ctm.a + ctm.b * ctm.b);
float sy = sqrtf(ctm.c * ctm.c + ctm.d * ctm.d);
float dot = ctm.a * ctm.c + ctm.b * ctm.d;
if (sx == sy && dot == 0.0f)
dev->pathfactor = sx;
else
dev->pathfactor = 1.0f;This extends the old logic from 0/90-degree cases to arbitrary rotation angles, while keeping the same strict fallback behavior. I’m keeping I tested this locally and |
|
@julian-smith-artifex-com If this revised approach looks good, I can update the PR with a new squashed commit. |
|
test_redact4 is currently failing due to a regression in mupdf in the latest master branch. So i don't think you should try to get the test to pass here. Tests are passing with this PR and git branch 1.27.x, so i think the PR is good. |
|
[rerunning tests with mupdf master as failure was from mupdf, not thie PR.] |
659e86b to
ed72ff4
Compare
|
I hope you don't mind, but i've taken the liberty of rebasing the PR tree on top of latest main. Hopefully it will still pass tests, and we can merge the PR. |
Bug 1: lineJoin was multiplied by pathfactor. stroke->linejoin is an enum (0=Miter, 1=Round, 2=Bevel) and should not be scaled. Note that lineCap is already correctly handled as plain integers without pathfactor multiplication. Bug 2: pathfactor calculation only handled some transform patterns correctly. Use sqrt(abs(a*d - b*c)) so uniform scaling with arbitrary rotation is handled correctly; for non-uniform scaling this yields the geometric mean of the scale factors. Fixed in: - src/extra.i (rebased build) - src/__init__.py (Python fallback)
ed72ff4 to
d547cdf
Compare
|
Thanks again for taking care of the earlier rebase. It looks like |
|
@julian-smith-artifex-com Checks passed, looks mergeable now! |
Fixes #4954
Changes
Bug 1:
lineJoinscaled bypathfactorstroke->linejoinis an enum (0=Miter, 1=Round, 2=Bevel) but was multiplied bypathfactor. Changed to emit the raw integer value, consistent with howlineCapis already handled.Bug 2:
pathfactorfalls back to 1 for non-uniform scalingThe original calculation only covered uniform scaling (
|a|==|d|) and 90° rotation (|b|==|c|). Changed to usesqrt(a² + b²)which handles arbitrary transforms.Note: For non-uniform scaling, stroke width is direction-dependent in general. This fix approximates it using the length of the transformed unit vector.
Files changed
src/extra.i— rebased buildsrc_classic/helper-devices.i— classic buildsrc/__init__.py— Python fallback