Skip to content

Feature/printer params#23

Merged
u8array merged 10 commits into
mainfrom
feature/printer-params
May 7, 2026
Merged

Feature/printer params#23
u8array merged 10 commits into
mainfrom
feature/printer-params

Conversation

@u8array
Copy link
Copy Markdown
Owner

@u8array u8array commented May 7, 2026

No description provided.

u8array added 8 commits May 7, 2026 17:14
Adds printSpeed, darkness, mediaType, printOrientation, defaultFont as
optional fields. All fields are .optional() so existing persisted designs
load unchanged.
Adds emit logic for printSpeed (^PR), darkness (^MD), mediaType (^MT),
printOrientation (^PO) and defaultFont (^CF). Order follows ZPL II
header convention; emits only when value is set, with darkness=0 treated
as a valid value rather than absence.
Parser now recognises ^PR (print speed), ^MD (darkness), ^MT (media
type), ^PO (print orientation) and extends ^CF to populate
labelConfig.defaultFont. Removes ^PR/^MT from the noop list. Tests cover
each command including the darkness=0 boundary and a full
generate-parse round-trip.
Adds 15 new keys under the label block for the printer-settings UI in
all 32 locales: printerSettingsHeading, printSpeed(+Hint), darkness(+Hint),
mediaType (+T/+D), printOrientation (+N/+I/+Indicator), defaultFont
(+Id/+Height). Translations generated via scripts/add_locale_key.local.py.
LabelConfigPanel gains a section for print speed, darkness, media type,
print orientation and default font. Empty inputs persist as undefined so
absent fields stay absent in the generated output. Darkness preserves 0
as a valid value via parseIntOrUndef.

Canvas shows a small badge in the top-right corner when print
orientation is set to upside down, signalling the printer-side flip
without rotating the design surface.
The CF handler parsed p[1] both via int() (for the parser-local cfHeight
state) and via parseInt() (to detect explicit height for labelConfig.
defaultFont). Both serve distinct purposes but the duplicate parse can
be replaced by a single parseInt with NaN-aware fallback.
…tions

The empty option in the mediaMode/mediaType/printOrientation selects
previously reused presetCustom ("Custom"), which is the right semantic
for the dimension-preset select but not for "unset, use printer's own
default". Adds a dedicated label.printerDefault key in all 32 locales
and points the three empty-state options at it.
Using `??` to merge the patch into the current value collapsed two
distinct states: "this key was not in the patch" and "the user just
cleared this input". The latter passes `{ height: undefined }`, but
`undefined ?? current.height` falls through to the old value, so
clearing the height field had no effect on stored defaultFont. Replaces
`??` with an `in` check so an explicit `undefined` overrides current.
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces comprehensive support for printer-specific settings, including print speed, darkness, media type, orientation, and default font configuration. These settings are integrated into the UI properties panel, ZPL generation, and parsing logic, with localized strings added across all supported languages. Feedback focuses on improving the user experience when configuring default fonts by allowing partial state updates in the UI and schema, ensuring robust ZPL parsing by trimming whitespace, and preventing invalid ZPL output for incomplete font definitions.

Comment thread src/components/Properties/PropertiesPanel.tsx Outdated
Comment thread src/lib/zplGenerator.ts Outdated
Comment thread src/lib/zplParser.ts
Comment thread src/lib/zplParser.ts
Comment thread src/types/ObjectType.ts Outdated
Replaces the nested defaultFont: { fontId, height } object with two
independent optional fields defaultFontId and defaultFontHeight. The
nested shape forced an all-or-nothing UI: typing one field at a time
either lost the partial input (deadlock) or required a fragile merge
helper that conflated 'absent' and 'cleared' states.

Flat fields let each input persist independently; the generator emits
^CF only when both are set. Removes mergeDefaultFont; tests updated
including a new pair that asserts ^CF is omitted on partial state.
@u8array
Copy link
Copy Markdown
Owner Author

u8array commented May 7, 2026

/gemini review

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This PR adds support for printer-specific ZPL settings (speed, darkness, media type, orientation, and default font) across the schema, UI, generator, and parser. It includes a new 'Printer settings' panel and an upside-down orientation indicator. Reviewer feedback suggests refining the ^CF command generation to support independent parameters and improving the robustness of MT and PO parsing against leading spaces.

Comment thread src/lib/zplGenerator.ts Outdated
Comment thread src/lib/zplParser.ts
The ^CF parameters are individually optional per Zebra spec: ^CF0 sets
the font without changing the height, ^CF,30 sets the height without
changing the font. Previously the generator required both fields and
would silently drop a partial command on round-trip. Now emits whichever
fields are set, with explicit round-trip tests for both partial forms.
@u8array u8array merged commit c475b9e into main May 7, 2026
2 checks passed
@u8array u8array deleted the feature/printer-params branch May 7, 2026 21:24
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