Rewrite label designer as an item-based canvas editor

- Items (text blocks, emoji) are placed freely: click to select, drag to
  move, arrow-key nudge, rotate to any angle, resize, duplicate, fit/center
- Emoji picker now covers the full emoji set via emoji-data-python
  (~1,900, 9 categories, name search, hover shows the name); thumbnails
  are rendered by Pillow with Noto Color Emoji so ZWJ sequences and flags
  display exactly as they print
- Designs save/open as JSON; last design restored on launch
This commit is contained in:
Gracious
2026-09-21 08:15:27 +01:00
parent f9daab05e4
commit dfe26919ad
4 changed files with 629 additions and 228 deletions
+9 -6
View File
@@ -82,15 +82,18 @@ python niimprint -c bluetooth -a "E2:E1:08:03:09:87" -r 90 -i examples/B21_80x50
## Label designer app
`label_app.py` is a small Tkinter app for designing and printing text + emoji labels:
`label_app.py` is a Tkinter app for designing and printing labels with text and emoji:
```
python label_app.py
```
- Pick a label size preset (or custom mm), type text (one line per row), click emojis to insert them
- Live 1-bit preview shows exactly what the printer will produce
- Auto-fit shrinks the font until the text fits the label
- Printer model / connection / address / density are remembered in `~/.config/niimprint-label/settings.json`
- Pick a label size preset (or custom mm)
- **+ Text** adds a text block; click any emoji in the picker (all ~1,900, searchable by name) to add it
- Click an item to select it, drag to move, arrow keys nudge (Shift = 10 px), Delete removes
- Selected item panel: edit text, size, angle (any degrees, or the ⟲/⟳ 90° buttons), X/Y, bold, alignment
- **Fit** resizes the item to fill the label; **Center H/V** aligns it
- The canvas shows the dithered 1-bit image exactly as the printer will produce it
- **Save…/Open…** store designs as JSON; the last design and printer settings are restored on launch
Fonts: DejaVu Sans (`/usr/share/fonts/TTF/`) for text and Noto Color Emoji (`/usr/share/fonts/noto/`) for emoji; edit `TEXT_FONTS` / `EMOJI_FONT` at the top of the file for other distros.
Fonts: DejaVu Sans (`/usr/share/fonts/TTF/`) for text and Noto Color Emoji (`/usr/share/fonts/noto/`) for emoji; edit `TEXT_FONTS` / `EMOJI_FONT` at the top of the file for other distros. Emoji are rendered by Pillow with the same font that prints, so the picker is WYSIWYG.