Skip to content

Insert: QR codes for a link or any text - #546

Open
NikitkaRa wants to merge 1 commit into
storytold:mainfrom
NikitkaRa:insert-qr-code
Open

NikitkaRa wants to merge 1 commit into
storytold:mainfrom
NikitkaRa:insert-qr-code

Conversation

@NikitkaRa

Copy link
Copy Markdown
Contributor

Summary

  • Adds Insert ▸ Text ▸ QR Code. The dialog asks for a link or any text and an error correction level (L/M/Q/H, default M).
  • The new insert.qrCode command {text, rect?, level?, link?} (also available to CLI and MCP) inserts a "QR Code N" group. The group holds a white square that includes the quiet zone, plus the dark modules as one vector path with a rectangle per run. The code stays sharp at any size and survives PPTX and PDF as ordinary shapes.
  • When the text is a URL (http(s)://, mailto:), it also becomes the group's click link in a show. The text goes into the alt text either way.
  • Empty text and text too long for a QR code are refused with an error. One undo removes the code.
  • New dependency: qrcode 0.14 (MIT/Apache-2.0) with default-features = false, so no image crate comes with it. It's a code dependency, not an asset.

Closes #154

Test plan

  • qr_path_draws_the_finder_patterns: the size (version 3 plus the quiet zone), the top-left finder run, and oversized input refused
  • insert_qr_code_adds_a_linked_group: a group with two children and unique ids, a URL becomes the link and plain text doesn't, empty or oversized text is refused, undo works, and the code survives a PPTX round trip
  • Rendered a slide, and its PPTX round trip, to PNG on the box and decoded both with OpenCV's QR detector: both read back https://github.com/storytold/deckcraft/issues/154
  • cargo xtask ci
  • Manual check of the ribbon button and dialog (the box has no display, so the UI wasn't checked by screenshot)

anishguduru pushed a commit to anishguduru/deckcraft that referenced this pull request Oct 16, 2026
…Œ œ Ÿ ...) (storytold#546)

pdfcraft_fonts::win_ansi, edit's is_win_ansi_char and the xtask demo
encoder each carried a hand-written subset of WinAnsiEncoding's 0x80-0x9F
row (quotes, dashes, euro, trademark) and left out Š š Ž ž Œ œ Ÿ ƒ † ‡ ˆ
˜ ‰ ‹ ›. Text editing therefore treated š/ž as non-WinAnsi and sent them
to the Type3 fallback font (or refused them without craft-fonts), and
every other generator (forms, annotations, OCR layer, redaction overlay,
signatures, create) wrote them as '?'.

win_ansi now goes through a new win_ansi_byte, which reads the 0x80-0x9F
codes from the same ISO 32000-2 Annex D table the text extractor decodes
with, and is_win_ansi_char reuses it. xtask doesn't depend on
pdfcraft-fonts, so its demo encoder gets the full row with a pointer to
the shared table. č/ć are not in WinAnsi and still use the fallback.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
PowerPoint users add QR codes through the QR4Office add-in; DeckCraft
had nothing. Insert > QR Code opens a dialog for the link or text and
the error correction level, and insert.qrCode draws the code as a group:
a white square with the quiet zone and the dark modules as one vector
path (a rectangle per run), so it stays sharp at any size and in PPTX
and PDF. A URL also becomes the group's click link in a show, and the
text goes into the alt text. Uses the qrcode crate (MIT/Apache-2.0)
without its image feature.

Co-authored-by: Cursor <cursoragent@cursor.com>

@FredApps FredApps left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ReviewerA — source-read COMMENT (not an approval)

I read the head of the diff: Insert gains QR codes for a link or any text. The lock gains qrcode 0.14.1 (without its image feature; the application draws the modules itself) and a comment in Cargo.toml ties it to #154. qrcode is a small, widely used crate with no further dependencies, which makes it a reasonable choice; the maintainers still approve every new dependency. The text length must be bounded (QR has a maximum capacity and the encoder returns an error beyond it, which must be shown), the quiet zone must be kept for scanners, and the inserted code should be a vector drawing so that it scales when printed. A test that encodes a known string and compares the module matrix is the proof. I have not run it, and no exact-head CI result exists for this head. Nothing was run.

I ran nothing and have no exact-head CI result for this PR, so this is not an approval. Where a diff was long I read its code hunks rather than every generated or documentation line.

Status: waiting_author.

This branch has not been deployed

No deployments
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.

Missing QR Code functionality

2 participants