-
Notifications
You must be signed in to change notification settings - Fork 1
Thread the resolved printer through rendering for correct per-model output - #56
Open
willumpie82 wants to merge 2 commits into
Open
Thread the resolved printer through rendering for correct per-model output #56willumpie82 wants to merge 2 commits into
willumpie82 wants to merge 2 commits into
Conversation
Rendering (preview and the actual print payload) and printing each constructed a plain DymoLabeler, ignoring model-specific subclasses like DymoLabelManagerWirelessPnP (labelle-org/labelle#<PR>) entirely -- so a model with its own calibration/margins would render and print using the generic (wrong, for it) defaults regardless of which printer was actually selected. - label_builder.py's render functions now accept an optional resolved `device`, used via DymoLabeler.for_device when given. Also passes the labeler's real per-model vertical resolution into RenderContext, so the preview's mm-ruler labels match reality for a model whose cross-tape and along-tape resolutions genuinely differ (previously always assumed the same PIXELS_PER_MM for both axes). - printer_service.py's actual print path (print_label, print_bitmap) now builds its DymoLabeler the same way, so what's printed always matches the resolved device's own protocol. - app.py's preview and cut-mark-print paths resolve a device via the new resolve_device_for_render (best-effort: falls back to generic rendering for a virtual printer, unresolved printer_id, or scan failure, rather than turning a preview request into an error the way an actual print correctly would). Also adds 24mm as a selectable tape size (client + server validation): physically supported per the LabelManager Wireless PnP's own datasheet, though only for models whose SUPPORTED_TAPE_SIZES_MM actually includes it -- selecting it for one that doesn't still fails clearly at print time. A fully correct fix would query the selected device's own supported sizes instead of this static list; out of scope here. Full test suite: 300/300 passing (three pre-existing tests needed `git config --global --add safe.directory` in the sandbox they were verified in -- a testing-environment quirk, not a code issue).
Adds an "autoCut" checkbox to the settings bar that sends the printer's
hardware cut command after printing, wired through printer_service.py's
two print call sites as cut=settings.get("autoCut", False).
Deliberately kept separate from the persisted per-printer settings and
from the existing cutMark feature (which only draws a dotted line for a
manual cut): some models crash if sent an unconditional cut with no
cutter installed (labelle-org/labelle#81), so this is a non-persisted,
per-session toggle that defaults off and resets on reload or printer
switch rather than silently following a printer selection to a unit
that can't handle it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Companion to labelle-org/labelle#156, which validates real calibration data for the DYMO LabelManager Wireless PnP (previously an unvalidated placeholder, ~7.1 px/mm, that produced "squished"/incorrectly-scaled output for that model).
That fix only has an effect if labelle-web actually uses it. Right now, rendering (preview and the print payload) and printing each construct a plain
DymoLabeler, ignoring device-specific calibration entirely — so a model with its own margins/resolution renders and prints using generic defaults regardless of which printer is actually selected.label_builder.py's render functions now accept an optional resolveddevice, used viaDymoLabeler.for_device()when given. Also passes the labeler's real per-model vertical resolution intoRenderContext, so the preview's mm-ruler labels match reality for a model whose cross-tape and along-tape resolutions genuinely differ (previously always assumed one sharedPIXELS_PER_MMfor both axes).printer_service.py's actual print path (print_label,print_bitmap) builds itsDymoLabelerthe same way, so what's printed always matches the resolved device's own protocol.app.py's preview and cut-mark-print paths resolve a device via a newresolve_device_for_render(best-effort: falls back to generic rendering for a virtual printer, unresolvedprinterId, or a scan failure, rather than turning a preview request into an error the way an actual print correctly would).SUPPORTED_TAPE_SIZES_MMactually includes it; selecting it for one that doesn't still fails clearly at print time. A fully correct fix would query the selected device's own supported sizes instead of this static list — out of scope here.Dependency note
This is written against
labelle's currentmainAPI (DymoLabeler.for_device()). labelle#156 targetsdevelopinstead (per a maintainer's standing preference for device-specific work), whoseDymoLabelerAPI differs meaningfully (nofor_device(),height_px→get_label_height_px(), preview engines take the labeler instance directly, etc.) — so depending on which branch labelle-org ends up releasing the fix from, this PR may need adjusting to match. Flagging that now rather than have it be a surprise in review.Test plan
ruff checkclean (pre-existing findings elsewhere in the codebase left untouched, no config enforces them here)🤖 Generated with Claude Code