Skip to content

Commit 335d8ac

Browse files
fix: rMQR add sub-alignment vertical timing columns per rmqr_table_d1
Add vertical timing/alignment columns at Zint-specified positions: R7x43→col21, R7x59→cols19,39, R7x77→cols25,51, etc. Data placement correctly skips these function pattern columns. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent b4d6d91 commit 335d8ac

1 file changed

Lines changed: 19 additions & 4 deletions

File tree

src/encoders/rmqr.ts

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -278,11 +278,27 @@ export function encodeRMQR(text: string, options: RMQROptions = {}): boolean[][]
278278
// 4. Timing patterns on all 4 edges
279279
for (let c = 7; c < cols - 1; c++) {
280280
if (matrix[0]![c] === null) matrix[0]![c] = c % 2 === 0;
281-
if (matrix[rows - 1]![c] === null) matrix[rows - 1]![c] = (c + rows + 1) % 2 === 0;
281+
if (matrix[rows - 1]![c] === null) matrix[rows - 1]![c] = (c + 1) % 2 === 0;
282282
}
283283
for (let r = 1; r < rows - 1; r++) {
284-
if (matrix[r]![0] === null) matrix[r]![0] = r % 2 === 0;
285-
if (matrix[r]![cols - 1] === null) matrix[r]![cols - 1] = (r + 1) % 2 === 0;
284+
if (matrix[r]![0] === null) matrix[r]![0] = (r + 1) % 2 === 0;
285+
if (matrix[r]![cols - 1] === null) matrix[r]![cols - 1] = r % 2 === 0;
286+
}
287+
288+
// 4b. Sub-alignment vertical timing columns (rMQR-specific)
289+
// Column positions from rmqr_table_d1, indexed by width group
290+
// These must be placed BEFORE data, as they are function patterns
291+
const widthGroupIdx = [43, 59, 77, 99, 139].indexOf(cols);
292+
// prettier-ignore
293+
const SUB_ALIGN: number[][] = [
294+
[21], [19,39], [25,51], [23,49,75], [27,55,83,111],
295+
];
296+
if (widthGroupIdx >= 0) {
297+
for (const ac of SUB_ALIGN[widthGroupIdx]!) {
298+
for (let r = 0; r < rows; r++) {
299+
matrix[r]![ac] = r % 2 === 0;
300+
}
301+
}
286302
}
287303

288304
// 5. Format info from pre-computed Zint tables (18 bits each side)
@@ -319,7 +335,6 @@ export function encodeRMQR(text: string, options: RMQROptions = {}): boolean[][]
319335
let bitIdx = 0;
320336
let upward = true;
321337
for (let col = cols - 2; col >= 1; col -= 2) {
322-
// Skip timing column (not applicable for rMQR — no column 6 timing)
323338
const rowOrder = upward
324339
? Array.from({ length: rows }, (_, i) => rows - 1 - i)
325340
: Array.from({ length: rows }, (_, i) => i);

0 commit comments

Comments
 (0)