ptouch-label CLIを追加して差込印刷を拡張
コマンド名を機能に合わせて整理し、SVGテンプレート+JSON/YAMLの差込印刷とメディア情報取得を使いやすくする。 Made-with: Cursor
This commit is contained in:
@@ -31,21 +31,25 @@ export LIBPTOUCH_LIB=/usr/local/lib/libptouch.so
|
||||
|
||||
(`cmake --install` で共有ライブラリをインストールした場合は、通常は `libptouch` 名でローダが解決します。)
|
||||
|
||||
## コマンド `ptouch-print-png`(PNG/SVG)
|
||||
## コマンド `ptouch-label`(PNG/SVG)
|
||||
|
||||
C の `ptouch-print` と同様の流れで、**PNG/SVG 入力**(`-w`/`-H` や 1bit ラスターは扱いません)を扱います。`gem install` 後は PATH に `ptouch-print-png` が入ります。
|
||||
C の `ptouch-print` と同様の流れで、**PNG/SVG 入力**(`-w`/`-H` や 1bit ラスターは扱いません)を扱います。`gem install` 後は PATH に `ptouch-label` が入ります。
|
||||
SVG は現在装着テープの印字可能幅に合わせて自動拡大・縮小します(USB 接続が必要)。
|
||||
後方互換のため `ptouch-print-png` も引き続き使えます。
|
||||
|
||||
オプションは C 側に合わせ、**`-p` / `--pid`** で USB 製品 ID(16 進可)を指定できます。省略時は PT-P900W(`Libptouch::USB_PID_PTP900W` = `0x2085`)。例: PT-P750W `0x2062`、PT-P710BT `0x20af`(`libptouch.h` / `Libptouch` 定数と同じ)。
|
||||
また、`--template`(SVG)と `--data`(JSON/YAML)を使うと `data-field` 属性をキーにした差込印刷が可能です。
|
||||
|
||||
開発ツリーからそのまま試す例:
|
||||
|
||||
```bash
|
||||
bundle exec ruby -I lib exe/ptouch-print-png --help
|
||||
bundle exec ruby -I lib exe/ptouch-print-png -n -f ../samples/your.png
|
||||
bundle exec ruby -I lib exe/ptouch-print-png -n -f ../samples/your.svg
|
||||
bundle exec ruby -I lib exe/ptouch-print-png --status -p 0x2062
|
||||
bundle exec ruby -I lib exe/ptouch-print-png -f ../samples/your.png -p 0x20af
|
||||
bundle exec ruby -I lib exe/ptouch-label --help
|
||||
bundle exec ruby -I lib exe/ptouch-label -n -f ../samples/your.png
|
||||
bundle exec ruby -I lib exe/ptouch-label -n -f ../samples/your.svg
|
||||
bundle exec ruby -I lib exe/ptouch-label -n --template ../samples/your_template.svg --data ../samples/your_data.yml
|
||||
bundle exec ruby -I lib exe/ptouch-label --media-info
|
||||
bundle exec ruby -I lib exe/ptouch-label --status -p 0x2062
|
||||
bundle exec ruby -I lib exe/ptouch-label -f ../samples/your.png -p 0x20af
|
||||
```
|
||||
|
||||
## 使用例
|
||||
@@ -92,9 +96,9 @@ ctx.dispose
|
||||
|
||||
## API の範囲
|
||||
|
||||
- 実行ファイル `ptouch-print-png` … PNG/SVG(`-f`, `-t`, `-p`, `-n`, `-S`, `-V`, `-h`)。ステータスは JSON(`status_bytes` を `parse_status` したもの、`raw_bytes` 除く)
|
||||
- 実行ファイル `ptouch-label`(互換: `ptouch-print-png`)… PNG/SVG(`-f`, `-t`, `-p`, `-n`, `-M`, `-S`, `-V`, `-h`, `--template`, `--data`)。`-M` は現在テープ情報(幅 mm・DPI 等)を JSON 出力、`-S` はステータス JSON 出力
|
||||
- `Libptouch::Context` … `open_usb` / `open_usb_vid_pid` / `close` / `dispose`
|
||||
- `check_raster` / `print_raster` / `png_file_to_raster` / `svg_file_to_raster_fit_current_tape` / `status_bytes` / `status_hash` / `current_media_info`
|
||||
- `current_media_info` には `print_dpi` / `feed_dpi` / `tape_width_mm` / `min_feed_mm` などを含む
|
||||
- `current_media_info` には `print_dpi` / `feed_dpi` / `tape_width_mm` / `printable_height_dots` / `min_feed_mm` などを含む(テープ幅方向は `printable_height_dots`)
|
||||
- `Libptouch.parse_status(raw)` … 32 バイトを Hash に展開(機種・テープ幅・**テープ種類**・色・**状態(status_kind)**・エラービット・`raw_hex` など)
|
||||
- C の `libptouch_status_fprint`(`FILE *`)は FFI からはバインドしていません。テキスト出力の代わりに `parse_status` / `status_hash` を使ってください。
|
||||
|
||||
Reference in New Issue
Block a user