From ac8757f36f0e78428a89e2e68962931665c51df7 Mon Sep 17 00:00:00 2001 From: maettuu Date: Sun, 20 Jul 2025 13:26:04 +0200 Subject: [PATCH] Add regression test for negative LW normalization in gs operator MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ensure that negative “LW” entries in an ExtGState dictionary are converted to their absolute values when the “gs” operator is processed. See PR https://github.com/mozilla/pdf.js/pull/19639 --- test/unit/evaluator_spec.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/test/unit/evaluator_spec.js b/test/unit/evaluator_spec.js index 0aa6bc685..643a965f0 100644 --- a/test/unit/evaluator_spec.js +++ b/test/unit/evaluator_spec.js @@ -423,4 +423,30 @@ describe("evaluator", function () { expect(operatorList.length).toEqual(0); }); }); + + describe("graphics-state operators", function () { + it("should convert negative line width to absolute value in the graphic state", async function () { + const gState = new Dict(); + gState.set("LW", -5); + const extGState = new Dict(); + extGState.set("GSneg", gState); + + const resources = new ResourcesMock(); + resources.ExtGState = extGState; + + const stream = new StringStream("/GSneg gs"); + const result = await runOperatorListCheck( + partialEvaluator, + stream, + resources + ); + + expect(result.fnArray).toEqual([OPS.setGState]); + + const stateEntries = result.argsArray[0][0]; + const lwEntry = stateEntries.find(([key]) => key === "LW"); + expect(lwEntry).toBeDefined(); + expect(lwEntry[1]).toEqual(5); + }); + }); });