MAD Designer iconMAD

Barcode Closure Implementation Plan

For agentic workers: REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (- [ ]) syntax for tracking.

Goal: Make barcode elements render headlessly on Linux and Windows (HTML/JSON exports embed a data-URI PNG), and give the Windows WPF designer the same barcode creation and editing capabilities as iOS and macOS.

Architecture: MADBarcodes grows a UIKit-free render core: MADBarcode keeps one zint encode path and gains -renderedPNGData (libpng’s simplified write API over zint’s RGB bitmap), while every UIKit/AppKit draw path stays behind #if __APPLE__. The framework, libpng and zint join the Linux and Windows builds; MAD links the framework, and MADPrintPageElementBarcode exposes the PNG to the page walk so the exporters can embed it. mad serve grows a barcode element kind, barcode content editing and a symbology catalogue; the WPF designer consumes them for palette insert, canvas preview and inspector options.

Tech Stack: Objective-C (ARC), zint 2.16.0 (BSD-3-Clause), libpng 1.6.59, CMake (Linux), PowerShell + clang (Windows engine), WPF/.NET 10 (Windows app), GNUstep Testing.h (headless suites), xUnit (WPF suites).

Spec: C:\dev\MAD-Windows-DevEnv\BARCODE_CLOSURE.md (with docs/archive/MAD_BARCODES.md §1 and §5 as background).

Global Constraints

Review Focus

  1. A barcode element with a static input and no query field must render its static text and export it, not crash on a nil dictionary key (existing MADPrintPageElementBarcode reads rowData[fieldKey] unconditionally).
  2. A barcode whose zint encode fails (invalid data for the symbology) must export the line’s text and no <img>, not a corrupt PNG or a crash.
  3. A long/UTF-8 input must not overflow zint’s fixed primary[128] buffer on the second input.
  4. Documents without barcodes must keep the pinned London export bytes exactly (no unconditional JSON member, no shared CSS change).
  5. The Apple drawInRect: / MADBarcodeCache path must keep its current behaviour: same zint options, same error messages, same image type.
  6. The Windows designer must survive a barcode element whose preview PNG is absent (zint failure) — text fallback, no null dereference.

Task 1: Pin zint and libpng in the Linux and Windows library builds

Files:

Interfaces:

libpng   1.6.59  -  -  86a3e4b501f7f50e392c4e456ea158893e9a595b1c63eb88c7bb9f6cf8772dad  https://download.sourceforge.net/libpng/libpng-1.6.59.tar.gz
zint     2.16.0  -  -  e1077fd5846bdd0128fef3ab8c3c28e93e450d2efaf1424d0aa96e0c9e514591  https://github.com/zint/zint/archive/refs/tags/2.16.0.tar.gz

Order matters: both are appended after zlib (already present) and libpng before zint.

git add Linux/libraries.conf Linux/lib/libraries.sh Windows/Engine/libraries.conf Windows/Engine/build.ps1
git commit -s -m "build: pin zint 2.16.0 and libpng 1.6.59 for the Linux and Windows builds"

Task 2: The portable render core, and MADBarcodes in the headless builds

Files:

Interfaces:

static void testFactoryBuildsCode128(void) {
    MADBarcode *barcode = [MADBarcode newBarcodeWithType: MADBarcodeTypeCODE128];
    MAD_PASS(barcode != nil, "the factory builds Code 128");
    MAD_PASS_EQUAL(barcode.name, @"Code 128 (ISO 15417)", "the name table answers the type's name");
}
static void testRenderedPNGDataIsAPNG(void) {
    MADBarcode *barcode = [MADBarcode newBarcodeWithType: MADBarcodeTypeCODE128];
    barcode.input = @"MAD-2026"; barcode.humanReadable = YES; barcode.barcodeHeight = 40;
    NSData *png = [barcode renderedPNGData];
    MAD_PASS(png.length > 8, "the render produced bytes");
    const uint8_t *bytes = png.bytes;
    MAD_PASS(bytes[0] == 0x89 && bytes[1] == 'P' && bytes[2] == 'N' && bytes[3] == 'G',
             "the bytes carry the PNG signature");
}
static void testInvalidInputReportsTheMessage(void) {
    MADBarcode *barcode = [MADBarcode newBarcodeWithType: MADBarcodeTypeCODE128];
    barcode.input = @"";
    NSString *message = nil;
    NSData *png = [barcode renderedPNGDataWithErrorMessage: &message];
    MAD_PASS(png == nil, "empty input does not render");
    MAD_PASS(message.length > 0, "the failed pass reports a message");
}

End with MAD_TEST_MAIN("MADBarcodesTests", MAD_TEST(testFactoryBuildsCode128), MAD_TEST(testRenderedPNGDataIsAPNG), MAD_TEST(testInvalidInputReportsTheMessage));.

git add MADBarcodes Linux/cmake/MADBarcodesSources.cmake Windows/Engine/cmake/MADBarcodesSources.cmake Linux/CMakeLists.txt Windows/Engine/build.ps1 Linux/Tests/MADBarcodesTests.m
git commit -s -m "feat(barcodes): add the PNG render core and build MADBarcodes headlessly"

Task 3: Engine integration — barcode elements render and export

Files:

Interfaces:

git add MAD/Source Linux/cmake/MADSources.cmake Windows/Engine/cmake/MADSources.cmake Linux/Tests/MADBarcodeExportTests.m Linux/CMakeLists.txt Windows/Engine/build.ps1
git commit -s -m "feat(mad): render barcode elements headlessly and embed them in the exporters"

Task 4: mad serve — barcode element kind, content, preview and catalogue

Files:

Interfaces:

git add CLI/Source/MADCLIServe.m
git commit -s -m "feat(cli): serve barcode elements, content, previews and the symbology catalogue"

Task 5: The WPF designer — palette, canvas preview and inspector

Files:

Interfaces:

git add Windows/App/Mad.Designer.Windows
git commit -s -m "feat(app): enable the barcode element in the Windows designer"

Task 6: WPF barcode tests and the smoke-test case

Files:

Interfaces:

git add Windows/App/Mad.Designer.Windows.Tests
git commit -s -m "test(app): pin the Windows barcode designer and its export"

Task 7: Licence register, About window and the documentation sweep

Files:

Interfaces:

git add ThirdParty docs AGENTS.md MADBarcodes/AGENTS.md Linux Windows/App Window/Engine README.md
git commit -s -m "docs: register zint and libpng and record the headless barcode build"

Task 8: Full verification, the summary, and the pull request

Files:

git add -A
git commit -s -m "docs: record the barcode-closure verification"
git push -u origin barcode-closure
gh pr create --base master --head barcode-closure \
  --title "Barcode closure: headless rendering and the Windows designer" \
  --body "<summary from the file>"