libptouch: P700/P900 families, optional JSON config, ESC i z and print sequencing

- Add printer_family and profile flags; load overrides from printer_families.json
- Set ESC i z page byte from profile; pass prof into ptouch_fill_esc_iz
- End print with 0x1A only (drop FF prefix); extend Ruby FFI and CLI media info
- Add reference/ptp_raster_ref.adoc; install config under share/ptouch_label

Made-with: Cursor
This commit is contained in:
knb
2026-04-19 12:20:21 +09:00
parent 3f2eb464aa
commit bfd6adda42
18 changed files with 456 additions and 47 deletions

View File

@@ -39,6 +39,18 @@ typedef enum {
LIBPTOUCH_ERR_IMAGE = 7,
} libptouch_err_t;
/**
* リファレンス上の系統PT-P750W/P710BT = P700、PT-P900 系 = P900
* DPI の値で分岐する代わりに、この系統を使う。
*/
typedef enum {
LIBPTOUCH_FAMILY_UNKNOWN = 0,
/** PT-P750W / PT-P710BTcv_ptp750w_710bt_jpn_raster_102.pdf 系) */
LIBPTOUCH_FAMILY_P700 = 1,
/** PT-P900 / P900W / P950NW / P910BT 等cv_ptp900_jpn_raster_102.pdf 系) */
LIBPTOUCH_FAMILY_P900 = 2,
} libptouch_printer_family_t;
/** lsusb 例: PT-P900W — Brother Industries, Ltd (04f9:2085) */
#define LIBPTOUCH_USB_VID_BROTHER 0x04f9u
#define LIBPTOUCH_USB_PID_PTP900W 0x2085u
@@ -49,6 +61,11 @@ typedef enum {
libptouch_ctx *libptouch_create(void);
void libptouch_destroy(libptouch_ctx *ctx);
/**
* 系統の短い英語ラベル("p700" / "p900" / "unknown"。UI やログ用。
*/
const char *libptouch_printer_family_label(libptouch_printer_family_t family);
/** 人が読める英語メッセージ(スレッド非安全: ctx ごと) */
const char *libptouch_strerror(const libptouch_ctx *ctx);
libptouch_err_t libptouch_last_error(const libptouch_ctx *ctx);
@@ -76,7 +93,7 @@ typedef struct {
typedef struct {
uint8_t media_width_code; /**< status[10] */
uint8_t media_kind_code; /**< status[11] */
double print_dpi; /**< 印字幅方向 DPI現状 180 or 360 */
double print_dpi; /**< 印字幅方向 DPI系統既定または設定ファイル上書き */
double feed_dpi; /**< 送り方向 DPIESC i d の基準) */
double tape_width_mm; /**< 装着テープ幅mm。例: 3.5, 6, 9, 12, 18, 24, 36 */
uint16_t printable_dots; /**< 現在テープで印字可能な幅(ドット) */
@@ -84,6 +101,8 @@ typedef struct {
uint16_t right_margin_dots; /**< 右余白(ドット) */
uint16_t min_feed_dots; /**< 仕様上の最小送り量(ドット)。現在は 14 */
double min_feed_mm; /**< 最小送り量mm */
/** @ref libptouch_printer_family_t系統不明時は @ref LIBPTOUCH_FAMILY_UNKNOWN */
uint32_t printer_family;
} libptouch_media_info_t;
/**
@@ -113,8 +132,8 @@ libptouch_err_t libptouch_trim_right_blank_columns(
/**
* 1 ビット packed ラスターを USB で印刷(各機種のラスター PDF 準拠)。
* 印字前にステータスでテープ幅を読み、印刷可能ドット内に画像を中央配置する。
* width_dots は装着テープの印刷可能幅以下であること。PT-P900 系は幅 360dpi、
* PT-P750W / PT-P710BT は幅 180dpicv_ptp750w_710bt_jpn_raster_102.pdfのドット列を想定
* width_dots は装着テープの印刷可能幅以下であること。系統は @ref libptouch_get_current_media_info
* の printer_family で判別できるP900 系は主に 360dpi 相当ドット列、P700 系は 180dpi 相当)
* @param margin_mm 余白フィード量。0 のとき PDF の最小 1mm14 ドット)相当を送る。
* 印刷時は内部でドット列を転置する(テープ幅方向とバッファの縦横の対応)。
* @param data 1 行あたり width_dots ビットを ceil(width_dots/8) バイトで並べた連続領域