From a2d2548867bdbc1ea675287f4420ddc35bfd39c3 Mon Sep 17 00:00:00 2001 From: Dominic Radermacher Date: Mon, 11 Oct 2021 10:36:58 +0200 Subject: [PATCH 01/53] fix generation of version.h --- cmake/gitversion.cmake | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cmake/gitversion.cmake b/cmake/gitversion.cmake index 5854a7f..d0c2a96 100644 --- a/cmake/gitversion.cmake +++ b/cmake/gitversion.cmake @@ -30,6 +30,9 @@ else() string(STRIP "${GIT_COMMITS}" GIT_COMMITS) string(STRIP "${GIT_DIFF}" GIT_DIFF) string(STRIP "${GIT_TAG}" GIT_TAG) + if (${GIT_COMMITS} STREQUAL ${GIT_TAG}) + set(GIT_COMMITS "0") + endif() endif() set(VERSION "const char* GIT_BRANCH=\"${GIT_BRANCH}\"; From f74d06877601cc63763b0788bd658aca142e717f Mon Sep 17 00:00:00 2001 From: Dominic Radermacher Date: Mon, 11 Oct 2021 11:50:54 +0200 Subject: [PATCH 02/53] add install target --- CMakeLists.txt | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index d5318ae..757f557 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,6 +8,7 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake") # Configure required dependencies find_package(Gettext REQUIRED) find_package(GD REQUIRED) +find_package(Git REQUIRED) find_package(PkgConfig REQUIRED) find_package(Intl REQUIRED) @@ -63,3 +64,11 @@ ADD_CUSTOM_COMMAND( ${CMAKE_BINARY_DIR}/_version.h COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/gitversion.cmake) + +include(GNUInstallDirs) +set(CMAKE_INSTALL_PREFIX "/usr") + +install(TARGETS ptouch-print +) + +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/ptouch-print.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1) From e96817663717acedb8e0f7144dde26e07c416e2b Mon Sep 17 00:00:00 2001 From: Dominic Radermacher Date: Mon, 11 Oct 2021 19:31:15 +0200 Subject: [PATCH 03/53] fix text centering --- src/ptouch-print.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/ptouch-print.c b/src/ptouch-print.c index daff4ee..f5feb57 100644 --- a/src/ptouch-print.c +++ b/src/ptouch-print.c @@ -89,7 +89,10 @@ int print_img(ptouch_dev ptdev, gdImage *im) printf(_("maximum printing width for this tape is %ipx\n"), tape_width); return -1; } - offset=64-(gdImageSY(im)/2); /* always print centered */ + //offset=64-(gdImageSY(im)/2); /* always print centered */ + size_t max_pixels=ptouch_get_max_width(ptdev); + offset=((int)max_pixels / 2)-(gdImageSY(im)/2); /* always print centered */ + printf("max_pixels=%d, offset=%d\n", max_pixels, offset); if ((ptdev->devinfo->flags & FLAG_RASTER_PACKBITS) == FLAG_RASTER_PACKBITS) { if (debug) { printf("enable PackBits mode\n"); @@ -277,10 +280,18 @@ gdImage *render_text(char *font, char *line[], int lines, int tape_width) if (debug) { printf("debug: needed (max) height is %ipx\n", max_height); } + if ((max_height * lines) > tape_width) { + printf("Font size %d too large for %d lines\n", fsz, lines); + return NULL; + } + /* calculate unused pixels */ + int unused_px = tape_width - (max_height * lines); /* now render lines */ for (i=0; i Date: Tue, 5 Apr 2022 20:25:54 +0200 Subject: [PATCH 04/53] add debug output --- src/ptouch-print.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/ptouch-print.c b/src/ptouch-print.c index f5feb57..51c0ae1 100644 --- a/src/ptouch-print.c +++ b/src/ptouch-print.c @@ -527,6 +527,9 @@ int main(int argc, char *argv[]) printf("tape color = %02x\n", ptdev->status->tape_color); printf("text color = %02x\n", ptdev->status->text_color); printf("error = %04x\n", ptdev->status->error); + if (debug) { + ptouch_rawstatus(ptdev->status); + } exit(0); } else if (strcmp(&argv[i][1], "-image") == 0) { if ((im=image_load(argv[++i])) == NULL) { From ffc1b1f7b1248d2e09d257aa6653cdd1e0415d0c Mon Sep 17 00:00:00 2001 From: Dominic Radermacher Date: Sun, 11 Sep 2022 06:25:35 +0200 Subject: [PATCH 05/53] =?UTF-8?q?media=20type=20info=20now=20also=20with?= =?UTF-8?q?=20text=20output,=20thanks=20to=20S=C3=B6nke=20Peters?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/ptouch.h | 4 +++ src/libptouch.c | 70 ++++++++++++++++++++++++++++++++++++++++++++++ src/ptouch-print.c | 6 ++-- 3 files changed, 77 insertions(+), 3 deletions(-) diff --git a/include/ptouch.h b/include/ptouch.h index b56a349..8a05b25 100644 --- a/include/ptouch.h +++ b/include/ptouch.h @@ -107,3 +107,7 @@ int ptouch_info_cmd(ptouch_dev ptdev, int size_x); int ptouch_rasterstart(ptouch_dev ptdev); int ptouch_sendraster(ptouch_dev ptdev, uint8_t *data, size_t len); void ptouch_list_supported(); + +const char* pt_mediatype(unsigned char media_type); +const char* pt_tapecolor(unsigned char tape_color); +const char* pt_textcolor(unsigned char text_color); diff --git a/src/libptouch.c b/src/libptouch.c index 51fa814..415a9ac 100644 --- a/src/libptouch.c +++ b/src/libptouch.c @@ -364,3 +364,73 @@ void ptouch_list_supported() } return; } + +const char* pt_mediatype(const uint8_t media_type) +{ + switch (media_type) { + case 0x00: return "No media"; break; + case 0x01: return "Laminated tape"; break; + case 0x03: return "Non-laminated tape"; break; + case 0x04: return "Fabric tape"; break; + case 0x11: return "Heat-shrink tube"; break; + case 0x13: return "Fle tape"; break; + case 0x14: return "Flexible ID tape"; break; + case 0x15: return "Satin tape"; break; + case 0xff: return "Incompatible tape"; break; + default: return "unknown"; + } +} + +const char* pt_tapecolor(const uint8_t tape_color) +{ + switch (tape_color) { + case 0x01: return "White"; break; + case 0x02: return "Other"; break; + case 0x03: return "Clear"; break; + case 0x04: return "Red"; break; + case 0x05: return "Blue"; break; + case 0x06: return "Yellow"; break; + case 0x07: return "Green"; break; + case 0x08: return "Black"; break; + case 0x09: return "Clear"; break; + case 0x20: return "Matte White"; break; + case 0x21: return "Matte Clear"; break; + case 0x22: return "Matte Silver"; break; + case 0x23: return "Satin Gold"; break; + case 0x24: return "Satin Silver"; break; + case 0x30: return "Blue (TZe-5[345]5)"; break; + case 0x31: return "Red (TZe-435)"; break; + case 0x40: return "Fluorescent Orange"; break; + case 0x41: return "Fluorescent Yellow"; break; + case 0x50: return "Berry Pink (TZe-MQP35)"; break; + case 0x51: return "Light Gray (TZe-MQL35)"; break; + case 0x52: return "Lime Green (TZe-MQG35)"; break; + case 0x60: return "Yellow"; break; + case 0x61: return "Pink"; break; + case 0x62: return "Blue"; break; + case 0x70: return "Heat-shrink Tube"; break; + case 0x90: return "White(Flex. ID)"; break; + case 0x91: return "Yellow(Flex. ID)"; break; + case 0xf0: return "Cleaning"; break; + case 0xf1: return "Stencil"; break; + case 0xff: return "Incompatible"; break; + default: return "unknown"; + } +} + +const char* pt_textcolor(const uint8_t text_color) +{ + switch (text_color) { + case 0x01: return "White"; break; + case 0x02: return "Other"; break; + case 0x04: return "Red"; break; + case 0x05: return "Blue"; break; + case 0x08: return "Black"; break; + case 0x0a: return "Gold"; break; + case 0x62: return "Blue(F)"; break; + case 0xf0: return "Cleaning"; break; + case 0xf1: return "Stencil"; break; + case 0xff: return "Incompatible"; break; + default: return "unknown"; + } +} diff --git a/src/ptouch-print.c b/src/ptouch-print.c index 51c0ae1..b959850 100644 --- a/src/ptouch-print.c +++ b/src/ptouch-print.c @@ -522,10 +522,10 @@ int main(int argc, char *argv[]) } } else if (strcmp(&argv[i][1], "-info") == 0) { printf(_("maximum printing width for this tape is %ipx\n"), tape_width); - printf("media type = %02x\n", ptdev->status->media_type); + printf("media type = %02x (%s)\n", ptdev->status->media_type, pt_mediatype(ptdev->status->media_type)); printf("media width = %d mm\n", ptdev->status->media_width); - printf("tape color = %02x\n", ptdev->status->tape_color); - printf("text color = %02x\n", ptdev->status->text_color); + printf("tape color = %02x (%s)\n", ptdev->status->tape_color, pt_tapecolor(ptdev->status->tape_color)); + printf("text color = %02x (%s)\n", ptdev->status->text_color, pt_textcolor(ptdev->status->text_color)); printf("error = %04x\n", ptdev->status->error); if (debug) { ptouch_rawstatus(ptdev->status); From 71396e8ff1f92f70bf67584a9b65315229fedfb6 Mon Sep 17 00:00:00 2001 From: Dominic Radermacher Date: Sun, 11 Sep 2022 06:29:44 +0200 Subject: [PATCH 06/53] change init to first invalidate, then init (maybe needed for some ptouch models?) --- src/libptouch.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/libptouch.c b/src/libptouch.c index 415a9ac..917edef 100644 --- a/src/libptouch.c +++ b/src/libptouch.c @@ -186,7 +186,11 @@ int ptouch_send(ptouch_dev ptdev, uint8_t *data, size_t len) int ptouch_init(ptouch_dev ptdev) { - char cmd[]="\x1b\x40"; /* 1B 40 = ESC @ = INIT */ + /* first invalidate, then send init command */ + uint8_t cmd[102]; + memset(cmd, 0, 100); + cmd[100] = 0x1b; /* ESC */ + cmd[101] = 0x40; /* @ */ return ptouch_send(ptdev, (uint8_t *)cmd, strlen(cmd)); } From f56d7ea740b5a0b00d6ae73f7afb2839d0a8aef4 Mon Sep 17 00:00:00 2001 From: Dominic Radermacher Date: Sun, 11 Sep 2022 06:45:00 +0200 Subject: [PATCH 07/53] fix some compile warnings --- CMakeLists.txt | 5 +++-- include/ptouch.h | 3 ++- src/libptouch.c | 4 +--- src/ptouch-print.c | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 757f557..94a9a13 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -46,14 +46,15 @@ target_include_directories(ptouch-print PUBLIC ${GD_INCLUDE_DIR} ${LIBUSB_INCLUDE_DIRS} ${CMAKE_BINARY_DIR} - ${Libintl_INCLUDE_DIRS} + ${Intl_INCLUDE_DIRS} ) # Configure linker target_link_libraries(ptouch-print ${GD_LIBRARIES} ${LIBUSB_LIBRARIES} - ${Libintl_LIBRARY} + ${LIBUSB_LINK_LIBRARIES} + ${Intl_LIBRARY} ) # Add a custom command that produces version.h, plus a dummy output that's diff --git a/include/ptouch.h b/include/ptouch.h index 8a05b25..d33c2b9 100644 --- a/include/ptouch.h +++ b/include/ptouch.h @@ -96,7 +96,7 @@ int ptouch_send(ptouch_dev ptdev, uint8_t *data, size_t len); int ptouch_init(ptouch_dev ptdev); int ptouch_lf(ptouch_dev ptdev); int ptouch_ff(ptouch_dev ptdev); -size_t ptouch_get_max_pixel_width(ptouch_dev ptdev); +size_t ptouch_get_max_width(ptouch_dev ptdev); size_t ptouch_get_tape_width(ptouch_dev ptdev); int ptouch_page_flags(ptouch_dev ptdev, uint8_t page_flags); int ptouch_eject(ptouch_dev ptdev); @@ -106,6 +106,7 @@ int ptouch_enable_packbits(ptouch_dev ptdev); int ptouch_info_cmd(ptouch_dev ptdev, int size_x); int ptouch_rasterstart(ptouch_dev ptdev); int ptouch_sendraster(ptouch_dev ptdev, uint8_t *data, size_t len); +void ptouch_rawstatus(uint8_t raw[32]); void ptouch_list_supported(); const char* pt_mediatype(unsigned char media_type); diff --git a/src/libptouch.c b/src/libptouch.c index 917edef..b68cb16 100644 --- a/src/libptouch.c +++ b/src/libptouch.c @@ -79,8 +79,6 @@ struct _pt_dev_info ptdevs[] = { {0,0,"",0,0,0} }; -void ptouch_rawstatus(uint8_t raw[32]); - int ptouch_open(ptouch_dev *ptdev) { libusb_device **devs; @@ -191,7 +189,7 @@ int ptouch_init(ptouch_dev ptdev) memset(cmd, 0, 100); cmd[100] = 0x1b; /* ESC */ cmd[101] = 0x40; /* @ */ - return ptouch_send(ptdev, (uint8_t *)cmd, strlen(cmd)); + return ptouch_send(ptdev, (uint8_t *)cmd, sizeof(cmd)); } int ptouch_enable_packbits(ptouch_dev ptdev) diff --git a/src/ptouch-print.c b/src/ptouch-print.c index b959850..7924413 100644 --- a/src/ptouch-print.c +++ b/src/ptouch-print.c @@ -92,7 +92,7 @@ int print_img(ptouch_dev ptdev, gdImage *im) //offset=64-(gdImageSY(im)/2); /* always print centered */ size_t max_pixels=ptouch_get_max_width(ptdev); offset=((int)max_pixels / 2)-(gdImageSY(im)/2); /* always print centered */ - printf("max_pixels=%d, offset=%d\n", max_pixels, offset); + printf("max_pixels=%ld, offset=%d\n", max_pixels, offset); if ((ptdev->devinfo->flags & FLAG_RASTER_PACKBITS) == FLAG_RASTER_PACKBITS) { if (debug) { printf("enable PackBits mode\n"); @@ -528,7 +528,7 @@ int main(int argc, char *argv[]) printf("text color = %02x (%s)\n", ptdev->status->text_color, pt_textcolor(ptdev->status->text_color)); printf("error = %04x\n", ptdev->status->error); if (debug) { - ptouch_rawstatus(ptdev->status); + ptouch_rawstatus((uint8_t *)ptdev->status); } exit(0); } else if (strcmp(&argv[i][1], "-image") == 0) { From 53987c4150ddad289fd7bb96eee7695d0b3b7be4 Mon Sep 17 00:00:00 2001 From: Dominic Radermacher Date: Wed, 5 Oct 2022 18:08:06 +0200 Subject: [PATCH 08/53] cosmetic changes (some are overdue since many years) --- CMakeLists.txt | 70 ++++++++++++++++++++---------------------- cmake/gitversion.cmake | 13 +++++--- src/libptouch.c | 10 +++--- src/ptouch-print.c | 28 ++++++++--------- 4 files changed, 61 insertions(+), 60 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 94a9a13..949010d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,10 +1,11 @@ cmake_minimum_required(VERSION 3.15) + project(ptouch-print C) -# Configure CMake -set(CMAKE_C_STANDARD 11) list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake") +set(CMAKE_C_STANDARD 11) + # Configure required dependencies find_package(Gettext REQUIRED) find_package(GD REQUIRED) @@ -15,18 +16,41 @@ find_package(Intl REQUIRED) pkg_check_modules(LIBUSB REQUIRED libusb-1.0) # Configure project executable -add_executable(ptouch-print) +add_executable(${PROJECT_NAME}) -target_sources(ptouch-print PUBLIC - version.h +target_include_directories(${PROJECT_NAME} PUBLIC + ${CMAKE_BINARY_DIR} # HB9HEI - location of generated version.h + ${CMAKE_SOURCE_DIR}/include + ${GD_INCLUDE_DIR} + ${LIBUSB_INCLUDE_DIRS} + ${Intl_INCLUDE_DIRS} +) + +target_link_libraries(${PROJECT_NAME} PRIVATE + ${GD_LIBRARIES} + ${LIBUSB_LIBRARIES} + ${LIBUSB_LINK_LIBRARIES} + ${Intl_LIBRARY} +) + +target_sources(${PROJECT_NAME} PRIVATE include/ptouch.h include/gettext.h src/libptouch.c src/ptouch-print.c ) -# Configure compiler -target_compile_options(ptouch-print PUBLIC +add_dependencies(${PROJECT_NAME} + git-version +) + +target_compile_definitions(${PROJECT_NAME} PUBLIC + LOCALEDIR="${CMAKE_INSTALL_LOCALEDIR}" + USING_CMAKE=1 + PACKAGE="ptouch-print" +) + +target_compile_options(${PROJECT_NAME} PUBLIC -g -Wall -Wextra @@ -35,37 +59,11 @@ target_compile_options(ptouch-print PUBLIC -fPIC ) -target_compile_definitions(ptouch-print PUBLIC - LOCALEDIR="${CMAKE_INSTALL_LOCALEDIR}" - USING_CMAKE=1 - PACKAGE="ptouch-print" +# HB9HEI - custom target that produces version.h (req. cmake 3.0) +add_custom_target(git-version ALL + ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/gitversion.cmake ) -target_include_directories(ptouch-print PUBLIC - include - ${GD_INCLUDE_DIR} - ${LIBUSB_INCLUDE_DIRS} - ${CMAKE_BINARY_DIR} - ${Intl_INCLUDE_DIRS} -) - -# Configure linker -target_link_libraries(ptouch-print - ${GD_LIBRARIES} - ${LIBUSB_LIBRARIES} - ${LIBUSB_LINK_LIBRARIES} - ${Intl_LIBRARY} -) - -# Add a custom command that produces version.h, plus a dummy output that's -# not produced, in order to force gitversion.cmake to always be re-run -# before the build -ADD_CUSTOM_COMMAND( - OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/version.h - ${CMAKE_BINARY_DIR}/_version.h - COMMAND ${CMAKE_COMMAND} -P - ${CMAKE_CURRENT_SOURCE_DIR}/cmake/gitversion.cmake) - include(GNUInstallDirs) set(CMAKE_INSTALL_PREFIX "/usr") diff --git a/cmake/gitversion.cmake b/cmake/gitversion.cmake index d0c2a96..92483ea 100644 --- a/cmake/gitversion.cmake +++ b/cmake/gitversion.cmake @@ -1,3 +1,6 @@ +# HB9HEI - required for autogen version.h +find_package(Git REQUIRED) + # Get commit hash execute_process(COMMAND git log --format='%H' -n 1 OUTPUT_VARIABLE GIT_COMMIT_HASH @@ -35,11 +38,11 @@ else() endif() endif() -set(VERSION "const char* GIT_BRANCH=\"${GIT_BRANCH}\"; -const char* GIT_COMMIT=\"${GIT_COMMIT_SHORT}\"; -const char* GIT_COMMITS=\"${GIT_COMMITS}\"; -const char* GIT_TAG=\"${GIT_TAG}\"; -const char* VERSION=\"${GIT_TAG}-r${GIT_COMMITS}-g${GIT_COMMIT_SHORT}${GIT_DIFF}\"; +set(VERSION "#define GIT_BRANCH \"${GIT_BRANCH}\" +#define GIT_COMMIT \"${GIT_COMMIT_SHORT}\" +#define GIT_COMMITS \"${GIT_COMMITS}\" +#define GIT_TAG \"${GIT_TAG}\" +#define VERSION \"${GIT_TAG}.r${GIT_COMMITS}.g${GIT_COMMIT_SHORT}${GIT_DIFF}\" ") message(DEBUG "Generated Version: \"${VERSION}\"") diff --git a/src/libptouch.c b/src/libptouch.c index b68cb16..b4389dc 100644 --- a/src/libptouch.c +++ b/src/libptouch.c @@ -114,7 +114,7 @@ int ptouch_open(ptouch_dev *ptdev) libusb_free_device_list(devs, 1); return -1; } - for (int k=0; ptdevs[k].vid > 0; k++) { + for (int k=0; ptdevs[k].vid > 0; ++k) { if ((desc.idVendor == ptdevs[k].vid) && (desc.idProduct == ptdevs[k].pid) && (ptdevs[k].flags >= 0)) { fprintf(stderr, _("%s found on USB bus %d, device %d\n"), ptdevs[k].name, @@ -255,7 +255,7 @@ int ptouch_eject(ptouch_dev ptdev) void ptouch_rawstatus(uint8_t raw[32]) { fprintf(stderr, _("debug: dumping raw status bytes\n")); - for (int i=0; i<32; i++) { + for (int i=0; i<32; ++i) { fprintf(stderr, "%02x ", raw[i]); if (((i+1) % 16) == 0) { fprintf(stderr, "\n"); @@ -281,7 +281,7 @@ int ptouch_getstatus(ptouch_dev ptdev) fprintf(stderr, _("read error: %s\n"), libusb_error_name(r)); return -1; } - tries++; + ++tries; if (tries > 10) { fprintf(stderr, _("timeout while waiting for status response\n")); return -1; @@ -291,7 +291,7 @@ int ptouch_getstatus(ptouch_dev ptdev) if (buf[0]==0x80 && buf[1]==0x20) { memcpy(ptdev->status, buf, 32); ptdev->tape_width_px=0; - for (i=0; tape_info[i].mm > 0; i++) { + for (i=0; tape_info[i].mm > 0; ++i) { if (tape_info[i].mm == buf[10]) { ptdev->tape_width_px=tape_info[i].px; } @@ -359,7 +359,7 @@ int ptouch_sendraster(ptouch_dev ptdev, uint8_t *data, size_t len) void ptouch_list_supported() { printf("Supported printers (some might have quirks)\n"); - for (int i=0; ptdevs[i].vid > 0; i++) { + for (int i=0; ptdevs[i].vid > 0; ++i) { if ((ptdevs[i].flags & FLAG_PLITE) != FLAG_PLITE) { printf("\t%s\n", ptdevs[i].name); } diff --git a/src/ptouch-print.c b/src/ptouch-print.c index 7924413..6106b7a 100644 --- a/src/ptouch-print.c +++ b/src/ptouch-print.c @@ -201,7 +201,7 @@ int find_fontsize(int want_px, char *font, char *text) int save=0; int brect[8]; - for (int i=4; ; i++) { + for (int i=4; ; ++i) { if (gdImageStringFT(NULL, &brect[0], -1, font, i, 0.0, 0, 0, text) != NULL) { break; } @@ -244,7 +244,7 @@ gdImage *render_text(char *font, char *line[], int lines, int tape_width) fsz=fontsize; printf(_("setting font size=%i\n"), fsz); } else { - for (i=0; i x) { x=tmp; @@ -267,7 +267,7 @@ gdImage *render_text(char *font, char *line[], int lines, int tape_width) /* gdImageStringFT(im,brect,fg,fontlist,size,angle,x,y,string) */ /* find max needed line height for ALL lines */ int max_height=0; - for (i=0; i= argc) || (argv[i+1][0] == '-')) { break; } - i++; + ++i; } } else if (strcmp(&argv[i][1], "-version") == 0) { printf(_("ptouch-print version %s by Dominic Radermacher\n"), VERSION); @@ -498,7 +498,7 @@ int main(int argc, char *argv[]) return 1; } tape_width=ptouch_get_tape_width(ptdev); - for (i=1; i= argc) || (argv[i+1][0] == '-')) { break; } - i++; + ++i; line[lines]=argv[i]; } if (lines) { From 6b82cd6166745505849004cd3ef4a21cfb2336e6 Mon Sep 17 00:00:00 2001 From: Dominic Radermacher Date: Thu, 24 Nov 2022 06:45:01 +0100 Subject: [PATCH 09/53] small cosmetic change to CMakeLists.txt --- CMakeLists.txt | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 949010d..3a20ddb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,6 +4,8 @@ project(ptouch-print C) list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake") +include(GNUInstallDirs) +set(CMAKE_INSTALL_PREFIX /usr) set(CMAKE_C_STANDARD 11) # Configure required dependencies @@ -64,10 +66,6 @@ add_custom_target(git-version ALL ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/gitversion.cmake ) -include(GNUInstallDirs) -set(CMAKE_INSTALL_PREFIX "/usr") +install(TARGETS ${PROJECT_NAME} DESTINATION bin) -install(TARGETS ptouch-print -) - -INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/ptouch-print.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1) +install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/ptouch-print.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1) From 01d661493f4a148a69d47ede3ecac29ca069b7c8 Mon Sep 17 00:00:00 2001 From: Dominic Radermacher Date: Mon, 13 Mar 2023 11:17:03 +0100 Subject: [PATCH 10/53] update manpage and project url --- README | 2 +- ptouch-print.1 | 9 ++++++--- src/libptouch.c | 2 +- src/ptouch-print.c | 2 +- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/README b/README index fc64c6c..b3e6a6b 100644 --- a/README +++ b/README @@ -12,7 +12,7 @@ Maybe others work too (please report USB VID and PID so I can include support for further models, too). Further info can be found at: -https://familie-radermacher.ch/dominic/projekte/ptouch-print/ +https://dominic.familie-radermacher.ch/projekte/ptouch-print/ Compile instructions: diff --git a/ptouch-print.1 b/ptouch-print.1 index bfe8b20..05ddc49 100644 --- a/ptouch-print.1 +++ b/ptouch-print.1 @@ -1,10 +1,10 @@ .\" Man page for ptouch-print .\" -.\" Copyright (C) 2015-2021 Dominic Radermacher +.\" Copyright (C) 2015-2023 Dominic Radermacher .\" .\" You may distribute under the terms of the GNU General Public License. .\" -.TH PTOUCH-PRINT 1 "2021-08-30" "1.4.3" "ptouch printer util" +.TH PTOUCH-PRINT 1 "2023-03-13" "1.5" "ptouch printer util" .SH NAME ptouch-print \- a command line tool to use Brother Ptouch label printers .SH SYNOPSIS @@ -76,6 +76,9 @@ Display version information and exit. .TP .BR \-\-info Show info about the tape detected (like printing width etc.) and exit. +.TP +.BR \-\-list-supported +List all supported printers .SH DEFAULTS The default font used is 'DejaVuSans'. @@ -109,4 +112,4 @@ The image file must be palette based PNG format with two colors. .SH AUTHOR Written by Dominic Radermacher (dominic@familie-radermacher.ch). -Also see https://familie-radermacher.ch/dominic/projekte/ptouch-print/ +Also see https://dominic.familie-radermacher.ch/projekte/ptouch-print/ diff --git a/src/libptouch.c b/src/libptouch.c index b4389dc..24d684a 100644 --- a/src/libptouch.c +++ b/src/libptouch.c @@ -1,7 +1,7 @@ /* libptouch - functions to help accessing a brother ptouch - Copyright (C) 2013-2021 Dominic Radermacher + Copyright (C) 2013-2023 Dominic Radermacher This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 3 as diff --git a/src/ptouch-print.c b/src/ptouch-print.c index 6106b7a..647c644 100644 --- a/src/ptouch-print.c +++ b/src/ptouch-print.c @@ -1,7 +1,7 @@ /* ptouch-print - Print labels with images or text on a Brother P-Touch - Copyright (C) 2015-2021 Dominic Radermacher + Copyright (C) 2015-2023 Dominic Radermacher This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 3 as From 8b631a7996c0c2e33a55dc8f645792693217f4be Mon Sep 17 00:00:00 2001 From: Dominic Radermacher Date: Mon, 22 May 2023 10:05:55 +0200 Subject: [PATCH 11/53] hopefully fix libitnl linking issues --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3a20ddb..d2d491e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,7 +32,7 @@ target_link_libraries(${PROJECT_NAME} PRIVATE ${GD_LIBRARIES} ${LIBUSB_LIBRARIES} ${LIBUSB_LINK_LIBRARIES} - ${Intl_LIBRARY} + ${Intl_LIBRARIES} ) target_sources(${PROJECT_NAME} PRIVATE From f22e844eed773cc8e9ac876ad102d58dc972bb38 Mon Sep 17 00:00:00 2001 From: Dominic Radermacher Date: Fri, 13 Oct 2023 12:30:33 +0200 Subject: [PATCH 12/53] add (untested) support for PT-D460BT thanks to ccfreak2k --- include/ptouch.h | 6 +++++- src/libptouch.c | 33 +++++++++++++++++++++++++++++++++ src/ptouch-print.c | 12 ++++++++++++ 3 files changed, 50 insertions(+), 1 deletion(-) diff --git a/include/ptouch.h b/include/ptouch.h index d33c2b9..c38a20a 100644 --- a/include/ptouch.h +++ b/include/ptouch.h @@ -1,7 +1,7 @@ /* ptouch-print - Print labels with images or text on a Brother P-Touch - Copyright (C) 2015-2021 Dominic Radermacher + Copyright (C) 2015-2023 Dominic Radermacher This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 3 as @@ -32,6 +32,8 @@ struct _pt_tape_info { #define FLAG_PLITE (1 << 2) #define FLAG_P700_INIT (1 << 3) #define FLAG_USE_INFO_CMD (1 << 4) +#define FLAG_HAS_PRECUT (1 << 5) +#define FLAG_D460BT_MAGIC (1 << 6) typedef enum _pt_page_flags { FEED_NONE = 0x0, @@ -102,8 +104,10 @@ int ptouch_page_flags(ptouch_dev ptdev, uint8_t page_flags); int ptouch_eject(ptouch_dev ptdev); int ptouch_getstatus(ptouch_dev ptdev); int ptouch_getmaxwidth(ptouch_dev ptdev); +int ptouch_send_d460bt_magic(ptouch_dev ptdev); int ptouch_enable_packbits(ptouch_dev ptdev); int ptouch_info_cmd(ptouch_dev ptdev, int size_x); +int ptouch_send_precut_cmd(ptouch_dev ptdev, int precut); int ptouch_rasterstart(ptouch_dev ptdev); int ptouch_sendraster(ptouch_dev ptdev, uint8_t *data, size_t len); void ptouch_rawstatus(uint8_t raw[32]); diff --git a/src/libptouch.c b/src/libptouch.c index 24d684a..6f9d73d 100644 --- a/src/libptouch.c +++ b/src/libptouch.c @@ -71,6 +71,7 @@ struct _pt_dev_info ptdevs[] = { {0x04f9, 0x2065, "PT-P750W (PLite Mode)", 128, 180, FLAG_PLITE}, {0x04f9, 0x2073, "PT-D450", 128, 180, FLAG_USE_INFO_CMD}, /* Notes about the PT-D450: I'm unsure if print width really is 128px */ + {0x04f9, 0x20e0, "PT-D460BT", 128, 180, FLAG_P700_INIT|FLAG_USE_INFO_CMD|FLAG_HAS_PRECUT|FLAG_D460BT_MAGIC}, {0x04f9, 0x2074, "PT-D600", 128, 180, FLAG_RASTER_PACKBITS}, /* PT-D600 was reported to work, but with some quirks (premature cutting of tape, printing maximum of 73mm length) */ @@ -192,6 +193,21 @@ int ptouch_init(ptouch_dev ptdev) return ptouch_send(ptdev, (uint8_t *)cmd, sizeof(cmd)); } +/* Sends some magic commands to make prints work on the PT-D460BT. + These should go out after info_cmd and right before the raster data. */ +int ptouch_send_d460bt_magic(ptouch_dev ptdev) +{ + /* 1B 69 64 {n1} {n2} {n3} {n4} */ + uint8_t cmd[7]; + /* n1 and n2 are the length margin/spacing, in px? (uint16_t value, little endian) */ + /* A value of 0x06 is equivalent to the width margin on 6mm tape */ + /* The default for P-Touch software is 0x0e */ + /* n3 must be 0x4D or the print gets corrupted! */ + /* n4 seems to be ignored or reserved. */ + memcpy(cmd, "\x1b\x69\x64\x0e\x00\x4d\x00", 7); + return ptouch_send(ptdev, (uint8_t *)cmd, sizeof(cmd)); +} + int ptouch_enable_packbits(ptouch_dev ptdev) { /* 4D 00 = disable compression */ char cmd[] = "M\x02"; /* 4D 02 = enable packbits compression mode */ @@ -216,6 +232,23 @@ int ptouch_info_cmd(ptouch_dev ptdev, int size_x) cmd[8] = (uint8_t) (size_x >> 8) & 0xff; cmd[9] = (uint8_t) (size_x >> 16) & 0xff; cmd[10] = (uint8_t) (size_x >> 24) & 0xff; + if ((ptdev->devinfo->flags & FLAG_D460BT_MAGIC) == FLAG_D460BT_MAGIC) { + /* n9 is set to 2 in order to feed the last of the label and properly stop printing. */ + cmd[11] = (uint8_t) 0x02; + } + return ptouch_send(ptdev, cmd, sizeof(cmd)-1); +} + +/* If set, printer will prompt to cut blank tape before finishing the print. + If not set, printer will print normally with a big blank space on the label. + The printer ignores this value if the print is very short. */ +/* 0x80 horizontally mirrors the print */ +int ptouch_send_precut_cmd(ptouch_dev ptdev, int precut) +{ + char cmd[] = "\x1b\x69\x4d\x00"; + if (precut) { + cmd[3] = 0x40; + } return ptouch_send(ptdev, cmd, sizeof(cmd)-1); } diff --git a/src/ptouch-print.c b/src/ptouch-print.c index 647c644..a0e0804 100644 --- a/src/ptouch-print.c +++ b/src/ptouch-print.c @@ -109,6 +109,18 @@ int print_img(ptouch_dev ptdev, gdImage *im) printf(_("send print information command\n")); } } + if ((ptdev->devinfo->flags & FLAG_D460BT_MAGIC) == FLAG_D460BT_MAGIC) { + ptouch_send_d460bt_magic(ptdev); + if (debug) { + printf(_("send PT-D460BT magic commands\n")); + } + } + if ((ptdev->devinfo->flags & FLAG_HAS_PRECUT) == FLAG_HAS_PRECUT) { + ptouch_send_precut_cmd(ptdev, 1); + if (debug) { + printf(_("send precut command\n")); + } + } for (k=0; k Date: Tue, 28 Nov 2023 10:23:54 +0100 Subject: [PATCH 13/53] fix missing pixels on right side - thanks to patch from Boris-Chengbiao --- src/ptouch-print.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/ptouch-print.c b/src/ptouch-print.c index a0e0804..c01df2a 100644 --- a/src/ptouch-print.c +++ b/src/ptouch-print.c @@ -239,6 +239,16 @@ int needed_width(char *text, char *font, int fsz) return brect[2]-brect[0]; } +int offset_x(char *text, char *font, int fsz) +{ + int brect[8]; + + if (gdImageStringFT(NULL, &brect[0], -1, font, fsz, 0.0, 0, 0, text) != NULL) { + return -1; + } + return -brect[0]; +} + gdImage *render_text(char *font, char *line[], int lines, int tape_width) { int brect[8]; @@ -307,7 +317,8 @@ gdImage *render_text(char *font, char *line[], int lines, int tape_width) if (debug) { printf("debug: line %i pos=%i ofs=%i\n", i+1, pos, ofs); } - if ((p=gdImageStringFT(im, &brect[0], -black, font, fsz, 0.0, 0, pos, line[i])) != NULL) { + int off_x = offset_x(line[i], font_file, fsz); + if ((p=gdImageStringFT(im, &brect[0], -black, font, fsz, 0.0, off_x, pos, line[i])) != NULL) { printf(_("error in gdImageStringFT: %s\n"), p); } } From 06a8001bf4eb8904e848510df8414a58234296b5 Mon Sep 17 00:00:00 2001 From: "Florian J. Breunig" Date: Tue, 2 Jan 2024 21:54:57 +0100 Subject: [PATCH 14/53] added PT-D610BT Signed-off-by: Florian J. Breunig --- src/libptouch.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libptouch.c b/src/libptouch.c index 6f9d73d..4171fce 100644 --- a/src/libptouch.c +++ b/src/libptouch.c @@ -75,6 +75,7 @@ struct _pt_dev_info ptdevs[] = { {0x04f9, 0x2074, "PT-D600", 128, 180, FLAG_RASTER_PACKBITS}, /* PT-D600 was reported to work, but with some quirks (premature cutting of tape, printing maximum of 73mm length) */ + {0x04f9, 0x20e1, "PT-D610BT", 128, 180, FLAG_P700_INIT|FLAG_USE_INFO_CMD|FLAG_HAS_PRECUT|FLAG_D460BT_MAGIC}, //{0x04f9, 0x200d, "PT-3600", 384, 360, FLAG_RASTER_PACKBITS}, {0x04f9, 0x20af, "PT-P710BT", 128, 180, FLAG_RASTER_PACKBITS}, {0,0,"",0,0,0} From 935dd9a31b18158877f787dc17d01698826bd164 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Dvo=C5=99=C3=A1k?= Date: Fri, 5 Jan 2024 13:57:25 +0100 Subject: [PATCH 15/53] added PT-D410 --- src/libptouch.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libptouch.c b/src/libptouch.c index 4171fce..0991be6 100644 --- a/src/libptouch.c +++ b/src/libptouch.c @@ -69,6 +69,7 @@ struct _pt_dev_info ptdevs[] = { {0x04f9, 0x2062, "PT-P750W", 128, 180, FLAG_RASTER_PACKBITS|FLAG_P700_INIT}, {0x04f9, 0x2064, "PT-P700 (PLite Mode)", 128, 180, FLAG_PLITE}, {0x04f9, 0x2065, "PT-P750W (PLite Mode)", 128, 180, FLAG_PLITE}, + {0x04f9, 0x20df, "PT-D410", 128, 180, FLAG_USE_INFO_CMD|FLAG_HAS_PRECUT|FLAG_D460BT_MAGIC}, {0x04f9, 0x2073, "PT-D450", 128, 180, FLAG_USE_INFO_CMD}, /* Notes about the PT-D450: I'm unsure if print width really is 128px */ {0x04f9, 0x20e0, "PT-D460BT", 128, 180, FLAG_P700_INIT|FLAG_USE_INFO_CMD|FLAG_HAS_PRECUT|FLAG_D460BT_MAGIC}, From 312adc32090de93e092b38bff290594017dd0c4a Mon Sep 17 00:00:00 2001 From: Nedko Boshkilov Date: Sun, 11 Feb 2024 10:29:01 +0100 Subject: [PATCH 16/53] fix baseline for cyrillic font --- src/ptouch-print.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/ptouch-print.c b/src/ptouch-print.c index c01df2a..95a44f6 100644 --- a/src/ptouch-print.c +++ b/src/ptouch-print.c @@ -193,14 +193,19 @@ int write_png(gdImage *im, const char *file) int get_baselineoffset(char *text, char *font, int fsz) { int brect[8]; + int o_offset; + int text_offset; - if (strpbrk(text, "QgjpqyQµ") == NULL) { /* if we have none of these */ - return 0; /* we don't need an baseline offset */ - } /* else we need to calculate it */ + /* NOTE: This assumes that 'o' is always on the baseline */ gdImageStringFT(NULL, &brect[0], -1, font, fsz, 0.0, 0, 0, "o"); - int tmp=brect[1]-brect[5]; - gdImageStringFT(NULL, &brect[0], -1, font, fsz, 0.0, 0, 0, "g"); - return (brect[1]-brect[5])-tmp; + o_offset=brect[1]; + gdImageStringFT(NULL, &brect[0], -1, font, fsz, 0.0, 0, 0, text); + text_offset=brect[1]; + if (debug) { + printf(_("debug: o baseline offset - %d\n"), o_offset); + printf(_("debug: text baseline offset - %d\n"), text_offset); + } + return text_offset-o_offset; } /* -------------------------------------------------------------------- From dc5b974e744ddbfd45f8b8b4ca7a0a4e06a62b33 Mon Sep 17 00:00:00 2001 From: Ed Maste Date: Sat, 3 Feb 2024 16:42:40 -0500 Subject: [PATCH 17/53] Add precut flag to P700 With this change my P700 produces about 2cm of waste tape followed by the desired label, with no additional padding. As far as I know all of these printers have a cutter, so I am not sure what determines which modules should have this flag set -- perhaps some of them can cut at the end of a label only, not at the beginning? We could perhaps have a commandline option to disable precut. --- src/libptouch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libptouch.c b/src/libptouch.c index 0991be6..73aa763 100644 --- a/src/libptouch.c +++ b/src/libptouch.c @@ -65,7 +65,7 @@ struct _pt_dev_info ptdevs[] = { {0x04f9, 0x205f, "PT-E500", 128, 180, FLAG_RASTER_PACKBITS}, /* Note about the PT-E500: was reported by Jesse Becker with the remark that it also needs some padding (white pixels) */ - {0x04f9, 0x2061, "PT-P700", 128, 180, FLAG_RASTER_PACKBITS|FLAG_P700_INIT}, + {0x04f9, 0x2061, "PT-P700", 128, 180, FLAG_RASTER_PACKBITS|FLAG_P700_INIT|FLAG_HAS_PRECUT}, {0x04f9, 0x2062, "PT-P750W", 128, 180, FLAG_RASTER_PACKBITS|FLAG_P700_INIT}, {0x04f9, 0x2064, "PT-P700 (PLite Mode)", 128, 180, FLAG_PLITE}, {0x04f9, 0x2065, "PT-P750W (PLite Mode)", 128, 180, FLAG_PLITE}, From ad4e1541dee5de7ce8b19c153cd6666e85fe582f Mon Sep 17 00:00:00 2001 From: Ed Maste Date: Sat, 3 Feb 2024 16:46:09 -0500 Subject: [PATCH 18/53] Add cast to silence a compiler warning --- src/libptouch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libptouch.c b/src/libptouch.c index 73aa763..acbda17 100644 --- a/src/libptouch.c +++ b/src/libptouch.c @@ -251,7 +251,7 @@ int ptouch_send_precut_cmd(ptouch_dev ptdev, int precut) if (precut) { cmd[3] = 0x40; } - return ptouch_send(ptdev, cmd, sizeof(cmd)-1); + return ptouch_send(ptdev, (uint8_t *)cmd, sizeof(cmd)-1); } int ptouch_rasterstart(ptouch_dev ptdev) From 8aaeecd84b619587dc3885dd4fea4b7310c82fd4 Mon Sep 17 00:00:00 2001 From: Ed Maste Date: Sat, 3 Feb 2024 16:46:53 -0500 Subject: [PATCH 19/53] Add different libusb include path for FreeBSD --- include/ptouch.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/ptouch.h b/include/ptouch.h index c38a20a..5c007c7 100644 --- a/include/ptouch.h +++ b/include/ptouch.h @@ -18,7 +18,11 @@ */ #include +#ifdef __FreeBSD__ +#include +#else #include +#endif struct _pt_tape_info { uint8_t mm; /* Tape width in mm */ From a51fcf98f879b2505ea002d9b7385ba143c2febc Mon Sep 17 00:00:00 2001 From: Dominic Radermacher Date: Thu, 18 Apr 2024 09:29:38 +0200 Subject: [PATCH 20/53] add and install udev rules to enable non-root access (thanks to Patrick Huesmann for contribution) --- CMakeLists.txt | 5 +++++ udev/90-usb-ptouch-permissions.rules | 18 ++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 udev/90-usb-ptouch-permissions.rules diff --git a/CMakeLists.txt b/CMakeLists.txt index d2d491e..38741ee 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -69,3 +69,8 @@ add_custom_target(git-version ALL install(TARGETS ${PROJECT_NAME} DESTINATION bin) install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/ptouch-print.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1) + +if(EXISTS /etc/udev/rules.d) + install(FILES udev/90-usb-ptouch-permissions.rules DESTINATION /etc/udev/rules.d) + install(CODE "execute_process(COMMAND udevadm control --reload-rules)") +endif() diff --git a/udev/90-usb-ptouch-permissions.rules b/udev/90-usb-ptouch-permissions.rules new file mode 100644 index 0000000..907a826 --- /dev/null +++ b/udev/90-usb-ptouch-permissions.rules @@ -0,0 +1,18 @@ +# Enable non-root access for known ptouch printers +SUBSYSTEM == "usb", ATTRS{idVendor} == "04f9", ATTRS{idProduct} == "2007", MODE = "0666" +SUBSYSTEM == "usb", ATTRS{idVendor} == "04f9", ATTRS{idProduct} == "2011", MODE = "0666" +SUBSYSTEM == "usb", ATTRS{idVendor} == "04f9", ATTRS{idProduct} == "2019", MODE = "0666" +SUBSYSTEM == "usb", ATTRS{idVendor} == "04f9", ATTRS{idProduct} == "201f", MODE = "0666" +SUBSYSTEM == "usb", ATTRS{idVendor} == "04f9", ATTRS{idProduct} == "202c", MODE = "0666" +SUBSYSTEM == "usb", ATTRS{idVendor} == "04f9", ATTRS{idProduct} == "202d", MODE = "0666" +SUBSYSTEM == "usb", ATTRS{idVendor} == "04f9", ATTRS{idProduct} == "2041", MODE = "0666" +SUBSYSTEM == "usb", ATTRS{idVendor} == "04f9", ATTRS{idProduct} == "205e", MODE = "0666" +SUBSYSTEM == "usb", ATTRS{idVendor} == "04f9", ATTRS{idProduct} == "205f", MODE = "0666" +SUBSYSTEM == "usb", ATTRS{idVendor} == "04f9", ATTRS{idProduct} == "2061", MODE = "0666" +SUBSYSTEM == "usb", ATTRS{idVendor} == "04f9", ATTRS{idProduct} == "2062", MODE = "0666" +SUBSYSTEM == "usb", ATTRS{idVendor} == "04f9", ATTRS{idProduct} == "2073", MODE = "0666" +SUBSYSTEM == "usb", ATTRS{idVendor} == "04f9", ATTRS{idProduct} == "2074", MODE = "0666" +SUBSYSTEM == "usb", ATTRS{idVendor} == "04f9", ATTRS{idProduct} == "20af", MODE = "0666" +SUBSYSTEM == "usb", ATTRS{idVendor} == "04f9", ATTRS{idProduct} == "20df", MODE = "0666" +SUBSYSTEM == "usb", ATTRS{idVendor} == "04f9", ATTRS{idProduct} == "20e0", MODE = "0666" +SUBSYSTEM == "usb", ATTRS{idVendor} == "04f9", ATTRS{idProduct} == "20e1", MODE = "0666" From da9ed2600a3bffb6c52166f35ec186249528f075 Mon Sep 17 00:00:00 2001 From: Kevin Thibedeau Date: Mon, 10 Jun 2024 16:54:07 +0200 Subject: [PATCH 21/53] Add chain mode and set precut flag for PT-2700 --- include/ptouch.h | 2 +- po/de.po | 150 ++++++++++++++++++++++++++++---------------- po/en.po | 152 ++++++++++++++++++++++++++++----------------- po/ptouch.pot | 126 +++++++++++++++++++++++-------------- src/libptouch.c | 14 +++-- src/ptouch-print.c | 10 ++- 6 files changed, 286 insertions(+), 168 deletions(-) diff --git a/include/ptouch.h b/include/ptouch.h index 5c007c7..54e01f7 100644 --- a/include/ptouch.h +++ b/include/ptouch.h @@ -105,7 +105,7 @@ int ptouch_ff(ptouch_dev ptdev); size_t ptouch_get_max_width(ptouch_dev ptdev); size_t ptouch_get_tape_width(ptouch_dev ptdev); int ptouch_page_flags(ptouch_dev ptdev, uint8_t page_flags); -int ptouch_eject(ptouch_dev ptdev); +int ptouch_finalize(ptouch_dev ptdev, int chain); int ptouch_getstatus(ptouch_dev ptdev); int ptouch_getmaxwidth(ptouch_dev ptdev); int ptouch_send_d460bt_magic(ptouch_dev ptdev); diff --git a/po/de.po b/po/de.po index 90e0b6e..d67eab7 100644 --- a/po/de.po +++ b/po/de.po @@ -8,193 +8,233 @@ msgid "" msgstr "" "Project-Id-Version: ptouch-print 1.3.1\n" "Report-Msgid-Bugs-To: dominic@familie-radermacher.ch\n" -"POT-Creation-Date: 2015-12-29 14:22+0100\n" -"PO-Revision-Date: 2015-11-11 09:35+0100\n" -"Last-Translator: \n" +"POT-Creation-Date: 2024-05-23 22:20-0400\n" +"PO-Revision-Date: 2024-05-23 22:27-0400\n" +"Last-Translator: dominic@familie-radermacher.ch\n" "Language-Team: German \n" "Language: de\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" +"X-Generator: Poedit 2.4.2\n" -#: src/libptouch.c:59 +#: src/libptouch.c:95 src/libptouch.c:99 src/libptouch.c:103 #, c-format msgid "out of memory\n" msgstr "Nicht genug Speicher\n" -#: src/libptouch.c:63 +#: src/libptouch.c:107 #, c-format msgid "libusb_init() failed\n" msgstr "ptouch_init() fehlgeschlagen\n" -#: src/libptouch.c:72 +#: src/libptouch.c:116 #, c-format msgid "failed to get device descriptor" msgstr "" -#: src/libptouch.c:78 +#: src/libptouch.c:122 #, c-format msgid "%s found on USB bus %d, device %d\n" msgstr "Drucker %s am USB Bus %d, Gerät %d gefunden\n" -#: src/libptouch.c:83 +#: src/libptouch.c:137 #, c-format msgid "libusb_open error :%s\n" msgstr "" -#: src/libptouch.c:89 +#: src/libptouch.c:143 #, c-format msgid "error while detaching kernel driver: %s\n" msgstr "" -#: src/libptouch.c:93 +#: src/libptouch.c:147 #, c-format msgid "interface claim error: %s\n" msgstr "" -#: src/libptouch.c:101 +#: src/libptouch.c:158 #, c-format -msgid "" -"No P-Touch printer found on USB (remember to put switch to position E)\n" +msgid "No P-Touch printer found on USB (remember to put switch to position E)\n" msgstr "Kein P-Ptouch Drucker am USB gefunden (Schalter muss auf E stehen)\n" -#: src/libptouch.c:121 +#: src/libptouch.c:178 #, c-format msgid "write error: %s\n" msgstr "" -#: src/libptouch.c:125 -#, c-format -msgid "write error: could send only %i of %i bytes\n" -msgstr "" +#: src/libptouch.c:182 +#, fuzzy, c-format +#| msgid "read error: got %i instead of 32 bytes\n" +msgid "write error: could send only %i of %ld bytes\n" +msgstr "Lesefehler: %i anstatt 32 bytes empfangen\n" -#: src/libptouch.c:194 +#: src/libptouch.c:302 #, c-format msgid "debug: dumping raw status bytes\n" msgstr "" -#: src/libptouch.c:218 src/libptouch.c:263 +#: src/libptouch.c:326 src/libptouch.c:362 #, c-format msgid "read error: %s\n" msgstr "" -#: src/libptouch.c:223 +#: src/libptouch.c:331 #, c-format msgid "timeout while waiting for status response\n" msgstr "" -#: src/libptouch.c:231 -#, c-format -msgid "Error 1 = %02x\n" -msgstr "Fehlerbyte1 = %02x\n" - -#: src/libptouch.c:234 -#, c-format -msgid "Error 2 = %02x\n" -msgstr "Fehlerbyte2 = %02x\n" - -#: src/libptouch.c:244 +#: src/libptouch.c:345 #, c-format msgid "unknown tape width of %imm, please report this.\n" msgstr "Unbekannte Schriftband breite (%i mm), bitte melden\n" -#: src/libptouch.c:252 +#: src/libptouch.c:351 #, c-format msgid "got only 16 bytes... wondering what they are:\n" msgstr "nur 16 bytes empfangen... mal gucken was die sind:\n" -#: src/libptouch.c:256 +#: src/libptouch.c:355 #, c-format msgid "read error: got %i instead of 32 bytes\n" msgstr "Lesefehler: %i anstatt 32 bytes empfangen\n" -#: src/libptouch.c:259 +#: src/libptouch.c:358 #, c-format msgid "strange status:\n" msgstr "Seltsamer Status:\n" -#: src/libptouch.c:261 +#: src/libptouch.c:360 #, c-format msgid "trying to flush junk\n" msgstr "" -#: src/libptouch.c:266 +#: src/libptouch.c:365 #, c-format msgid "got another %i bytes. now try again\n" msgstr "weitere %i bytes empfangen. probiere es nochmal.\n" -#: src/ptouch-print.c:71 +#: src/ptouch-print.c:82 +#, c-format +msgid "nothing to print\n" +msgstr "" + +#: src/ptouch-print.c:89 #, c-format msgid "image is too large (%ipx x %ipx)\n" msgstr "Bild ist zu gross (%ipx x %ipx)\n" -#: src/ptouch-print.c:72 src/ptouch-print.c:356 +#: src/ptouch-print.c:90 src/ptouch-print.c:556 #, c-format msgid "maximum printing width for this tape is %ipx\n" msgstr "Maximal druckbare Breite für dieses Schriftband sind %ipx\n" -#: src/ptouch-print.c:77 +#: src/ptouch-print.c:104 #, c-format msgid "ptouch_rasterstart() failed\n" msgstr "ptouch_rasterstart() fehlgeschlagen\n" -#: src/ptouch-print.c:88 +#: src/ptouch-print.c:110 #, c-format -msgid "ptouch_send() failed\n" +msgid "send print information command\n" +msgstr "" + +#: src/ptouch-print.c:116 +#, c-format +msgid "send PT-D460BT magic commands\n" +msgstr "" + +#: src/ptouch-print.c:122 +#, c-format +msgid "send precut command\n" +msgstr "" + +#: src/ptouch-print.c:133 +#, fuzzy, c-format +#| msgid "ptouch_send() failed\n" +msgid "ptouch_sendraster() failed\n" msgstr "ptouch_send() fehlgeschlagen\n" -#: src/ptouch-print.c:128 +#: src/ptouch-print.c:182 #, c-format msgid "writing image '%s' failed\n" msgstr "Schreiben der Bilddatei '%s' fehlgeschlagen\n" -#: src/ptouch-print.c:197 +#: src/ptouch-print.c:206 +#, c-format +msgid "debug: o baseline offset - %d\n" +msgstr "" + +#: src/ptouch-print.c:207 +#, c-format +msgid "debug: text baseline offset - %d\n" +msgstr "" + +#: src/ptouch-print.c:266 +#, c-format +msgid "render_text(): %i lines, font = '%s'\n" +msgstr "" + +#: src/ptouch-print.c:269 #, c-format msgid "warning: font config not available\n" msgstr "Warnung: fontconfig ist nicht verfügbar\n" -#: src/ptouch-print.c:201 +#: src/ptouch-print.c:273 #, c-format msgid "setting font size=%i\n" msgstr "setze Zeichensatzgrösse=%i\n" -#: src/ptouch-print.c:205 +#: src/ptouch-print.c:277 #, c-format msgid "could not estimate needed font size\n" msgstr "Konnte die notwendige Zeichensatzgrösse nicht bestimmen\n" -#: src/ptouch-print.c:212 +#: src/ptouch-print.c:284 #, c-format msgid "choosing font size=%i\n" msgstr "Wähle Zeichensatzgrösse %i\n" -#: src/ptouch-print.c:226 src/ptouch-print.c:232 +#: src/ptouch-print.c:300 src/ptouch-print.c:328 #, c-format msgid "error in gdImageStringFT: %s\n" msgstr "Fehler in Funktion gdImageStringFT(): %s\n" -#: src/ptouch-print.c:299 +#: src/ptouch-print.c:495 #, c-format msgid "ptouch-print version %s by Dominic Radermacher\n" msgstr "ptouch-print Version %s von Dominic Radermacher\n" -#: src/ptouch-print.c:326 +#: src/ptouch-print.c:526 #, c-format msgid "ptouch_init() failed\n" msgstr "ptouch_init() fehlgeschlagen\n" -#: src/ptouch-print.c:329 +#: src/ptouch-print.c:529 #, c-format msgid "ptouch_getstatus() failed\n" msgstr "ptouch_getstatus() fehlgeschlagen\n" -#: src/ptouch-print.c:373 +#: src/ptouch-print.c:568 +#, c-format +msgid "failed to load image file\n" +msgstr "" + +#: src/ptouch-print.c:584 #, c-format msgid "could not render text\n" msgstr "Konnte Text nicht rendern\n" -#: src/ptouch-print.c:389 +#: src/ptouch-print.c:616 #, c-format -msgid "ptouch_eject() failed\n" -msgstr "ptouch_eject() fehlgeschlagen\n" +msgid "ptouch_finalize(%d) failed\n" +msgstr "ptouch_finalize(%d) fehlgeschlagen\n" + +#, c-format +#~ msgid "Error 1 = %02x\n" +#~ msgstr "Fehlerbyte1 = %02x\n" + +#, c-format +#~ msgid "Error 2 = %02x\n" +#~ msgstr "Fehlerbyte2 = %02x\n" diff --git a/po/en.po b/po/en.po index c7793c5..e50f765 100644 --- a/po/en.po +++ b/po/en.po @@ -7,194 +7,232 @@ msgid "" msgstr "" "Project-Id-Version: ptouch-print 1.3.1\n" "Report-Msgid-Bugs-To: dominic@familie-radermacher.ch\n" -"POT-Creation-Date: 2015-12-29 14:22+0100\n" -"PO-Revision-Date: 2015-11-11 09:47+0100\n" -"Last-Translator: \n" +"POT-Creation-Date: 2024-05-23 22:20-0400\n" +"PO-Revision-Date: 2024-05-23 22:26-0400\n" +"Last-Translator: dominic@familie-radermacher.ch\n" "Language-Team: English \n" "Language: en\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n" +"X-Generator: Poedit 2.4.2\n" -#: src/libptouch.c:59 +#: src/libptouch.c:95 src/libptouch.c:99 src/libptouch.c:103 #, c-format msgid "out of memory\n" msgstr "out of memory\n" -#: src/libptouch.c:63 +#: src/libptouch.c:107 #, c-format msgid "libusb_init() failed\n" msgstr "libusb_init() failed\n" -#: src/libptouch.c:72 +#: src/libptouch.c:116 #, c-format msgid "failed to get device descriptor" msgstr "failed to get device descriptor" -#: src/libptouch.c:78 +#: src/libptouch.c:122 #, c-format msgid "%s found on USB bus %d, device %d\n" msgstr "%s found on USB bus %d, device %d\n" -#: src/libptouch.c:83 +#: src/libptouch.c:137 #, c-format msgid "libusb_open error :%s\n" msgstr "libusb_open error :%s\n" -#: src/libptouch.c:89 +#: src/libptouch.c:143 #, c-format msgid "error while detaching kernel driver: %s\n" msgstr "error while detaching kernel driver: %s\n" -#: src/libptouch.c:93 +#: src/libptouch.c:147 #, c-format msgid "interface claim error: %s\n" msgstr "interface claim error: %s\n" -#: src/libptouch.c:101 +#: src/libptouch.c:158 #, c-format -msgid "" -"No P-Touch printer found on USB (remember to put switch to position E)\n" -msgstr "" -"No P-Touch printer found on USB (remember to put switch to position E)\n" +msgid "No P-Touch printer found on USB (remember to put switch to position E)\n" +msgstr "No P-Touch printer found on USB (remember to put switch to position E)\n" -#: src/libptouch.c:121 +#: src/libptouch.c:178 #, c-format msgid "write error: %s\n" msgstr "write error: %s\n" -#: src/libptouch.c:125 -#, c-format -msgid "write error: could send only %i of %i bytes\n" +#: src/libptouch.c:182 +#, fuzzy, c-format +#| msgid "write error: could send only %i of %i bytes\n" +msgid "write error: could send only %i of %ld bytes\n" msgstr "write error: could send only %i of %i bytes\n" -#: src/libptouch.c:194 +#: src/libptouch.c:302 #, c-format msgid "debug: dumping raw status bytes\n" msgstr "debug: dumping raw status bytes\n" -#: src/libptouch.c:218 src/libptouch.c:263 +#: src/libptouch.c:326 src/libptouch.c:362 #, c-format msgid "read error: %s\n" msgstr "read error: %s\n" -#: src/libptouch.c:223 +#: src/libptouch.c:331 #, c-format msgid "timeout while waiting for status response\n" msgstr "timeout while waiting for status response\n" -#: src/libptouch.c:231 -#, c-format -msgid "Error 1 = %02x\n" -msgstr "Error 1 = %02x\n" - -#: src/libptouch.c:234 -#, c-format -msgid "Error 2 = %02x\n" -msgstr "Error 2 = %02x\n" - -#: src/libptouch.c:244 +#: src/libptouch.c:345 #, c-format msgid "unknown tape width of %imm, please report this.\n" msgstr "unknown tape width of %imm, please report this.\n" -#: src/libptouch.c:252 +#: src/libptouch.c:351 #, c-format msgid "got only 16 bytes... wondering what they are:\n" msgstr "got only 16 bytes... wondering what they are:\n" -#: src/libptouch.c:256 +#: src/libptouch.c:355 #, c-format msgid "read error: got %i instead of 32 bytes\n" msgstr "read error: got %i instead of 32 bytes\n" -#: src/libptouch.c:259 +#: src/libptouch.c:358 #, c-format msgid "strange status:\n" msgstr "strange status:\n" -#: src/libptouch.c:261 +#: src/libptouch.c:360 #, c-format msgid "trying to flush junk\n" msgstr "trying to flush junk\n" -#: src/libptouch.c:266 +#: src/libptouch.c:365 #, c-format msgid "got another %i bytes. now try again\n" msgstr "got another %i bytes. now try again\n" -#: src/ptouch-print.c:71 +#: src/ptouch-print.c:82 +#, c-format +msgid "nothing to print\n" +msgstr "" + +#: src/ptouch-print.c:89 #, c-format msgid "image is too large (%ipx x %ipx)\n" msgstr "image is too large (%ipx x %ipx)\n" -#: src/ptouch-print.c:72 src/ptouch-print.c:356 +#: src/ptouch-print.c:90 src/ptouch-print.c:556 #, c-format msgid "maximum printing width for this tape is %ipx\n" msgstr "maximum printing width for this tape is %ipx\n" -#: src/ptouch-print.c:77 +#: src/ptouch-print.c:104 #, c-format msgid "ptouch_rasterstart() failed\n" msgstr "ptouch_rasterstart() failed\n" -#: src/ptouch-print.c:88 +#: src/ptouch-print.c:110 #, c-format -msgid "ptouch_send() failed\n" -msgstr "ptouch_send() failed\n" +msgid "send print information command\n" +msgstr "" -#: src/ptouch-print.c:128 +#: src/ptouch-print.c:116 +#, c-format +msgid "send PT-D460BT magic commands\n" +msgstr "" + +#: src/ptouch-print.c:122 +#, c-format +msgid "send precut command\n" +msgstr "" + +#: src/ptouch-print.c:133 +#, c-format +msgid "ptouch_sendraster() failed\n" +msgstr "ptouch_sendraster() failed\n" + +#: src/ptouch-print.c:182 #, c-format msgid "writing image '%s' failed\n" msgstr "writing image '%s' failed\n" -#: src/ptouch-print.c:197 +#: src/ptouch-print.c:206 +#, c-format +msgid "debug: o baseline offset - %d\n" +msgstr "" + +#: src/ptouch-print.c:207 +#, c-format +msgid "debug: text baseline offset - %d\n" +msgstr "" + +#: src/ptouch-print.c:266 +#, c-format +msgid "render_text(): %i lines, font = '%s'\n" +msgstr "" + +#: src/ptouch-print.c:269 #, c-format msgid "warning: font config not available\n" msgstr "warning: font config not available\n" -#: src/ptouch-print.c:201 +#: src/ptouch-print.c:273 #, c-format msgid "setting font size=%i\n" msgstr "setting font size=%i\n" -#: src/ptouch-print.c:205 +#: src/ptouch-print.c:277 #, c-format msgid "could not estimate needed font size\n" msgstr "could not estimate needed font size\n" -#: src/ptouch-print.c:212 +#: src/ptouch-print.c:284 #, c-format msgid "choosing font size=%i\n" msgstr "choosing font size=%i\n" -#: src/ptouch-print.c:226 src/ptouch-print.c:232 +#: src/ptouch-print.c:300 src/ptouch-print.c:328 #, c-format msgid "error in gdImageStringFT: %s\n" msgstr "error in gdImageStringFT: %s\n" -#: src/ptouch-print.c:299 +#: src/ptouch-print.c:495 #, c-format msgid "ptouch-print version %s by Dominic Radermacher\n" msgstr "ptouch-print version %s by Dominic Radermacher\n" -#: src/ptouch-print.c:326 +#: src/ptouch-print.c:526 #, c-format msgid "ptouch_init() failed\n" msgstr "ptouch_init() failed\n" -#: src/ptouch-print.c:329 +#: src/ptouch-print.c:529 #, c-format msgid "ptouch_getstatus() failed\n" msgstr "ptouch_getstatus() failed\n" -#: src/ptouch-print.c:373 +#: src/ptouch-print.c:568 +#, c-format +msgid "failed to load image file\n" +msgstr "" + +#: src/ptouch-print.c:584 #, c-format msgid "could not render text\n" msgstr "could not render text\n" -#: src/ptouch-print.c:389 +#: src/ptouch-print.c:616 #, c-format -msgid "ptouch_eject() failed\n" -msgstr "ptouch_eject() failed\n" +msgid "ptouch_finalize(%d) failed\n" +msgstr "ptouch_finalize(%d) failed\n" + +#, c-format +#~ msgid "Error 1 = %02x\n" +#~ msgstr "Error 1 = %02x\n" + +#, c-format +#~ msgid "Error 2 = %02x\n" +#~ msgstr "Error 2 = %02x\n" diff --git a/po/ptouch.pot b/po/ptouch.pot index 4307111..cb22f35 100644 --- a/po/ptouch.pot +++ b/po/ptouch.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: ptouch 1.3.3\n" "Report-Msgid-Bugs-To: dominic@familie-radermacher.ch\n" -"POT-Creation-Date: 2015-12-29 14:22+0100\n" +"POT-Creation-Date: 2024-05-23 22:20-0400\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -17,183 +17,213 @@ msgstr "" "Content-Type: text/plain; charset=CHARSET\n" "Content-Transfer-Encoding: 8bit\n" -#: src/libptouch.c:59 +#: src/libptouch.c:95 src/libptouch.c:99 src/libptouch.c:103 #, c-format msgid "out of memory\n" msgstr "" -#: src/libptouch.c:63 +#: src/libptouch.c:107 #, c-format msgid "libusb_init() failed\n" msgstr "" -#: src/libptouch.c:72 +#: src/libptouch.c:116 #, c-format msgid "failed to get device descriptor" msgstr "" -#: src/libptouch.c:78 +#: src/libptouch.c:122 #, c-format msgid "%s found on USB bus %d, device %d\n" msgstr "" -#: src/libptouch.c:83 +#: src/libptouch.c:137 #, c-format msgid "libusb_open error :%s\n" msgstr "" -#: src/libptouch.c:89 +#: src/libptouch.c:143 #, c-format msgid "error while detaching kernel driver: %s\n" msgstr "" -#: src/libptouch.c:93 +#: src/libptouch.c:147 #, c-format msgid "interface claim error: %s\n" msgstr "" -#: src/libptouch.c:101 +#: src/libptouch.c:158 #, c-format msgid "" "No P-Touch printer found on USB (remember to put switch to position E)\n" msgstr "" -#: src/libptouch.c:121 +#: src/libptouch.c:178 #, c-format msgid "write error: %s\n" msgstr "" -#: src/libptouch.c:125 +#: src/libptouch.c:182 #, c-format -msgid "write error: could send only %i of %i bytes\n" +msgid "write error: could send only %i of %ld bytes\n" msgstr "" -#: src/libptouch.c:194 +#: src/libptouch.c:302 #, c-format msgid "debug: dumping raw status bytes\n" msgstr "" -#: src/libptouch.c:218 src/libptouch.c:263 +#: src/libptouch.c:326 src/libptouch.c:362 #, c-format msgid "read error: %s\n" msgstr "" -#: src/libptouch.c:223 +#: src/libptouch.c:331 #, c-format msgid "timeout while waiting for status response\n" msgstr "" -#: src/libptouch.c:231 -#, c-format -msgid "Error 1 = %02x\n" -msgstr "" - -#: src/libptouch.c:234 -#, c-format -msgid "Error 2 = %02x\n" -msgstr "" - -#: src/libptouch.c:244 +#: src/libptouch.c:345 #, c-format msgid "unknown tape width of %imm, please report this.\n" msgstr "" -#: src/libptouch.c:252 +#: src/libptouch.c:351 #, c-format msgid "got only 16 bytes... wondering what they are:\n" msgstr "" -#: src/libptouch.c:256 +#: src/libptouch.c:355 #, c-format msgid "read error: got %i instead of 32 bytes\n" msgstr "" -#: src/libptouch.c:259 +#: src/libptouch.c:358 #, c-format msgid "strange status:\n" msgstr "" -#: src/libptouch.c:261 +#: src/libptouch.c:360 #, c-format msgid "trying to flush junk\n" msgstr "" -#: src/libptouch.c:266 +#: src/libptouch.c:365 #, c-format msgid "got another %i bytes. now try again\n" msgstr "" -#: src/ptouch-print.c:71 +#: src/ptouch-print.c:82 +#, c-format +msgid "nothing to print\n" +msgstr "" + +#: src/ptouch-print.c:89 #, c-format msgid "image is too large (%ipx x %ipx)\n" msgstr "" -#: src/ptouch-print.c:72 src/ptouch-print.c:356 +#: src/ptouch-print.c:90 src/ptouch-print.c:556 #, c-format msgid "maximum printing width for this tape is %ipx\n" msgstr "" -#: src/ptouch-print.c:77 +#: src/ptouch-print.c:104 #, c-format msgid "ptouch_rasterstart() failed\n" msgstr "" -#: src/ptouch-print.c:88 +#: src/ptouch-print.c:110 #, c-format -msgid "ptouch_send() failed\n" +msgid "send print information command\n" msgstr "" -#: src/ptouch-print.c:128 +#: src/ptouch-print.c:116 +#, c-format +msgid "send PT-D460BT magic commands\n" +msgstr "" + +#: src/ptouch-print.c:122 +#, c-format +msgid "send precut command\n" +msgstr "" + +#: src/ptouch-print.c:133 +#, c-format +msgid "ptouch_sendraster() failed\n" +msgstr "" + +#: src/ptouch-print.c:182 #, c-format msgid "writing image '%s' failed\n" msgstr "" -#: src/ptouch-print.c:197 +#: src/ptouch-print.c:206 +#, c-format +msgid "debug: o baseline offset - %d\n" +msgstr "" + +#: src/ptouch-print.c:207 +#, c-format +msgid "debug: text baseline offset - %d\n" +msgstr "" + +#: src/ptouch-print.c:266 +#, c-format +msgid "render_text(): %i lines, font = '%s'\n" +msgstr "" + +#: src/ptouch-print.c:269 #, c-format msgid "warning: font config not available\n" msgstr "" -#: src/ptouch-print.c:201 +#: src/ptouch-print.c:273 #, c-format msgid "setting font size=%i\n" msgstr "" -#: src/ptouch-print.c:205 +#: src/ptouch-print.c:277 #, c-format msgid "could not estimate needed font size\n" msgstr "" -#: src/ptouch-print.c:212 +#: src/ptouch-print.c:284 #, c-format msgid "choosing font size=%i\n" msgstr "" -#: src/ptouch-print.c:226 src/ptouch-print.c:232 +#: src/ptouch-print.c:300 src/ptouch-print.c:328 #, c-format msgid "error in gdImageStringFT: %s\n" msgstr "" -#: src/ptouch-print.c:299 +#: src/ptouch-print.c:495 #, c-format msgid "ptouch-print version %s by Dominic Radermacher\n" msgstr "" -#: src/ptouch-print.c:326 +#: src/ptouch-print.c:526 #, c-format msgid "ptouch_init() failed\n" msgstr "" -#: src/ptouch-print.c:329 +#: src/ptouch-print.c:529 #, c-format msgid "ptouch_getstatus() failed\n" msgstr "" -#: src/ptouch-print.c:373 +#: src/ptouch-print.c:568 +#, c-format +msgid "failed to load image file\n" +msgstr "" + +#: src/ptouch-print.c:584 #, c-format msgid "could not render text\n" msgstr "" -#: src/ptouch-print.c:389 +#: src/ptouch-print.c:616 #, c-format -msgid "ptouch_eject() failed\n" +msgid "ptouch_finalize(%d) failed\n" msgstr "" diff --git a/src/libptouch.c b/src/libptouch.c index acbda17..28b124a 100644 --- a/src/libptouch.c +++ b/src/libptouch.c @@ -48,7 +48,7 @@ struct _pt_dev_info ptdevs[] = { {0x04f9, 0x2007, "PT-2420PC", 128, 180, FLAG_RASTER_PACKBITS}, /* 180dpi, 128px, maximum tape width 24mm, must send TIFF compressed pixel data */ {0x04f9, 0x2011, "PT-2450PC", 128, 180, FLAG_RASTER_PACKBITS}, {0x04f9, 0x2019, "PT-1950", 128, 180, FLAG_RASTER_PACKBITS}, /* 180dpi, apparently 112px printhead ?, maximum tape width 18mm - unconfirmed if it works */ - {0x04f9, 0x201f, "PT-2700", 128, 180, FLAG_NONE}, + {0x04f9, 0x201f, "PT-2700", 128, 180, FLAG_HAS_PRECUT}, {0x04f9, 0x202c, "PT-1230PC", 128, 180, FLAG_NONE}, /* 180dpi, supports tapes up to 12mm - I don't know how much pixels it can print! */ /* Notes about the PT-1230PC: While it is true that this printer supports max 12mm tapes, it apparently expects > 76px data - the first 32px @@ -280,13 +280,17 @@ int ptouch_ff(ptouch_dev ptdev) return ptouch_send(ptdev, (uint8_t *)cmd, strlen(cmd)); } -/* print and cut tape */ -int ptouch_eject(ptouch_dev ptdev) +/* finish print and either cut or leave tape in machine */ +int ptouch_finalize(ptouch_dev ptdev, int chain) { - char cmd[]="\x1a"; - return ptouch_send(ptdev, (uint8_t *)cmd, strlen(cmd)); + char cmd_eject[]="\x1a"; /* Print command with feeding */ + char cmd_chain[]="\x0c"; /* Print command (no cut) */ + + char *cmd = chain ? cmd_chain : cmd_eject; + return ptouch_send(ptdev, (uint8_t *)cmd, 1); } + void ptouch_rawstatus(uint8_t raw[32]) { fprintf(stderr, _("debug: dumping raw status bytes\n")); diff --git a/src/ptouch-print.c b/src/ptouch-print.c index 95a44f6..b0cbd3e 100644 --- a/src/ptouch-print.c +++ b/src/ptouch-print.c @@ -57,6 +57,7 @@ char *save_png=NULL; int verbose=0; int fontsize=0; bool debug=false; +bool chain=false; /* -------------------------------------------------------------------- -------------------------------------------------------------------- */ @@ -428,6 +429,7 @@ void usage(char *progname) printf("\t\t\t\tIf the text contains spaces, use quotation marks\n\t\t\t\taround it.\n"); printf("\t--cutmark\t\tPrint a mark where the tape should be cut\n"); printf("\t--pad \t\tAdd n pixels padding (blank tape)\n"); + printf("\t--chain\t\t\tSkip final feed of label and any automatic cut\n"); printf("other commands:\n"); printf("\t--version\t\tshow version info (required for bug report)\n"); printf("\t--info\t\t\tshow info about detected tape\n"); @@ -464,6 +466,8 @@ int parse_args(int argc, char **argv) } } else if (strcmp(&argv[i][1], "-cutmark") == 0) { continue; /* not done here */ + } else if (strcmp(&argv[i][1], "-chain") == 0) { + chain=true; } else if (strcmp(&argv[i][1], "-debug") == 0) { debug=true; } else if (strcmp(&argv[i][1], "-info") == 0) { @@ -595,6 +599,8 @@ int main(int argc, char *argv[]) out=img_append(out, im); gdImageDestroy(im); im = NULL; + } else if (strcmp(&argv[i][1], "-chain") == 0) { + chain = true; } else if (strcmp(&argv[i][1], "-debug") == 0) { debug = true; } else { @@ -606,8 +612,8 @@ int main(int argc, char *argv[]) write_png(out, save_png); } else { print_img(ptdev, out); - if (ptouch_eject(ptdev) != 0) { - printf(_("ptouch_eject() failed\n")); + if (ptouch_finalize(ptdev, chain) != 0) { + printf(_("ptouch_finalize(%d) failed\n"), chain); return -1; } } From b904e22cf19bdb5cf344dc04a14fb712291c254e Mon Sep 17 00:00:00 2001 From: Dominic Radermacher Date: Sun, 11 Aug 2024 13:15:22 +0200 Subject: [PATCH 22/53] Add --force-tape-with, enables use of --writepng without the need of a printer connected (thanks to Didi Kohen) --- src/ptouch-print.c | 68 ++++++++++++++++++++++++++++++---------------- 1 file changed, 45 insertions(+), 23 deletions(-) diff --git a/src/ptouch-print.c b/src/ptouch-print.c index b0cbd3e..832b7bf 100644 --- a/src/ptouch-print.c +++ b/src/ptouch-print.c @@ -1,7 +1,7 @@ /* ptouch-print - Print labels with images or text on a Brother P-Touch - Copyright (C) 2015-2023 Dominic Radermacher + Copyright (C) 2015-2024 Dominic Radermacher This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 3 as @@ -50,14 +50,15 @@ void unsupported_printer(ptouch_dev ptdev); void usage(char *progname); int parse_args(int argc, char **argv); -// char *font_file="/usr/share/fonts/TTF/Ubuntu-M.ttf"; -// char *font_file="Ubuntu:medium"; -char *font_file="DejaVuSans"; -char *save_png=NULL; -int verbose=0; -int fontsize=0; -bool debug=false; -bool chain=false; +// char *font_file = "/usr/share/fonts/TTF/Ubuntu-M.ttf"; +// char *font_file = "Ubuntu:medium"; +char *font_file = "DejaVuSans"; +char *save_png = NULL; +int verbose = 0; +int fontsize = 0; +bool debug = false; +bool chain = false; +int forced_tape_width = 0; /* -------------------------------------------------------------------- -------------------------------------------------------------------- */ @@ -422,6 +423,8 @@ void usage(char *progname) printf("\t--font \t\tuse font or \n"); printf("\t--fontsize \tManually set fontsize\n"); printf("\t--writepng \tinstead of printing, write output to png file\n"); + printf("\t--force-tape-width \tSet tape width in pixels, use together with\n"); + printf("\t\t\t\t--writepng without a printer connected.\n"); printf("print commands:\n"); printf("\t--image \t\tprint the given image which must be a 2 color\n"); printf("\t\t\t\t(black/white) png\n"); @@ -464,6 +467,12 @@ int parse_args(int argc, char **argv) } else { usage(argv[0]); } + } else if (strcmp(&argv[i][1], "-force-tape-width") == 0) { + if (i+1status->media_type, pt_mediatype(ptdev->status->media_type)); @@ -622,7 +642,9 @@ int main(int argc, char *argv[]) if (im != NULL) { gdImageDestroy(im); } - ptouch_close(ptdev); + if (forced_tape_width > 0) { + ptouch_close(ptdev); + } libusb_exit(NULL); return 0; } From 9a0ef8c7d68ecabdddbb631559ffce48c9dc6376 Mon Sep 17 00:00:00 2001 From: Dominic Radermacher Date: Sun, 11 Aug 2024 13:31:20 +0200 Subject: [PATCH 23/53] Fix chain print support for the D460BT family (thanks to Guilherme Espada) --- include/ptouch.h | 1 + src/libptouch.c | 11 ++++++++++- src/ptouch-print.c | 12 +++++++++--- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/include/ptouch.h b/include/ptouch.h index 54e01f7..76d64e5 100644 --- a/include/ptouch.h +++ b/include/ptouch.h @@ -109,6 +109,7 @@ int ptouch_finalize(ptouch_dev ptdev, int chain); int ptouch_getstatus(ptouch_dev ptdev); int ptouch_getmaxwidth(ptouch_dev ptdev); int ptouch_send_d460bt_magic(ptouch_dev ptdev); +int ptouch_send_d460bt_chain(ptouch_dev ptdev); int ptouch_enable_packbits(ptouch_dev ptdev); int ptouch_info_cmd(ptouch_dev ptdev, int size_x); int ptouch_send_precut_cmd(ptouch_dev ptdev, int precut); diff --git a/src/libptouch.c b/src/libptouch.c index 28b124a..d20ea5d 100644 --- a/src/libptouch.c +++ b/src/libptouch.c @@ -195,6 +195,14 @@ int ptouch_init(ptouch_dev ptdev) return ptouch_send(ptdev, (uint8_t *)cmd, sizeof(cmd)); } +/* Sends some magic commands to enable chaining on the PT-D460BT. + These should go out right before magic commands. */ +int ptouch_send_d460bt_chain(ptouch_dev ptdev) +{ + uint8_t cmd[] = "\x1b\x69\x4b\x00"; + return ptouch_send(ptdev, (uint8_t *)cmd, sizeof(cmd)); +} + /* Sends some magic commands to make prints work on the PT-D460BT. These should go out after info_cmd and right before the raster data. */ int ptouch_send_d460bt_magic(ptouch_dev ptdev) @@ -286,7 +294,8 @@ int ptouch_finalize(ptouch_dev ptdev, int chain) char cmd_eject[]="\x1a"; /* Print command with feeding */ char cmd_chain[]="\x0c"; /* Print command (no cut) */ - char *cmd = chain ? cmd_chain : cmd_eject; + // The D460BT devices use a leading packet to indicate chaining instead. + char *cmd = (chain && (!(ptdev->devinfo->flags & FLAG_D460BT_MAGIC))) ? cmd_chain : cmd_eject; return ptouch_send(ptdev, (uint8_t *)cmd, 1); } diff --git a/src/ptouch-print.c b/src/ptouch-print.c index 832b7bf..600261a 100644 --- a/src/ptouch-print.c +++ b/src/ptouch-print.c @@ -41,7 +41,7 @@ void rasterline_setpixel(uint8_t* rasterline, size_t size, int pixel); int get_baselineoffset(char *text, char *font, int fsz); int find_fontsize(int want_px, char *font, char *text); int needed_width(char *text, char *font, int fsz); -int print_img(ptouch_dev ptdev, gdImage *im); +int print_img(ptouch_dev ptdev, gdImage *im, int chain); int write_png(gdImage *im, const char *file); gdImage *img_append(gdImage *in_1, gdImage *in_2); gdImage *img_cutmark(int tape_width); @@ -74,7 +74,7 @@ void rasterline_setpixel(uint8_t* rasterline, size_t size, int pixel) return; } -int print_img(ptouch_dev ptdev, gdImage *im) +int print_img(ptouch_dev ptdev, gdImage *im, int chain) { int d,i,k,offset,tape_width; uint8_t rasterline[(ptdev->devinfo->max_px)/8]; @@ -112,6 +112,12 @@ int print_img(ptouch_dev ptdev, gdImage *im) } } if ((ptdev->devinfo->flags & FLAG_D460BT_MAGIC) == FLAG_D460BT_MAGIC) { + if (chain) { + ptouch_send_d460bt_chain(ptdev); + if (debug) { + printf(_("send PT-D460BT chain commands\n")); + } + } ptouch_send_d460bt_magic(ptdev); if (debug) { printf(_("send PT-D460BT magic commands\n")); @@ -631,7 +637,7 @@ int main(int argc, char *argv[]) if (save_png) { write_png(out, save_png); } else { - print_img(ptdev, out); + print_img(ptdev, out, chain); if (ptouch_finalize(ptdev, chain) != 0) { printf(_("ptouch_finalize(%d) failed\n"), chain); return -1; From 9cae7f465baaaf9aa76d91c00156e3452aec59d5 Mon Sep 17 00:00:00 2001 From: Didi Kohen Date: Sun, 11 Aug 2024 13:53:05 +0200 Subject: [PATCH 24/53] improve udev rules --- udev/90-usb-ptouch-permissions.rules | 34 ++++++++++++++-------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/udev/90-usb-ptouch-permissions.rules b/udev/90-usb-ptouch-permissions.rules index 907a826..b9d9f66 100644 --- a/udev/90-usb-ptouch-permissions.rules +++ b/udev/90-usb-ptouch-permissions.rules @@ -1,18 +1,18 @@ # Enable non-root access for known ptouch printers -SUBSYSTEM == "usb", ATTRS{idVendor} == "04f9", ATTRS{idProduct} == "2007", MODE = "0666" -SUBSYSTEM == "usb", ATTRS{idVendor} == "04f9", ATTRS{idProduct} == "2011", MODE = "0666" -SUBSYSTEM == "usb", ATTRS{idVendor} == "04f9", ATTRS{idProduct} == "2019", MODE = "0666" -SUBSYSTEM == "usb", ATTRS{idVendor} == "04f9", ATTRS{idProduct} == "201f", MODE = "0666" -SUBSYSTEM == "usb", ATTRS{idVendor} == "04f9", ATTRS{idProduct} == "202c", MODE = "0666" -SUBSYSTEM == "usb", ATTRS{idVendor} == "04f9", ATTRS{idProduct} == "202d", MODE = "0666" -SUBSYSTEM == "usb", ATTRS{idVendor} == "04f9", ATTRS{idProduct} == "2041", MODE = "0666" -SUBSYSTEM == "usb", ATTRS{idVendor} == "04f9", ATTRS{idProduct} == "205e", MODE = "0666" -SUBSYSTEM == "usb", ATTRS{idVendor} == "04f9", ATTRS{idProduct} == "205f", MODE = "0666" -SUBSYSTEM == "usb", ATTRS{idVendor} == "04f9", ATTRS{idProduct} == "2061", MODE = "0666" -SUBSYSTEM == "usb", ATTRS{idVendor} == "04f9", ATTRS{idProduct} == "2062", MODE = "0666" -SUBSYSTEM == "usb", ATTRS{idVendor} == "04f9", ATTRS{idProduct} == "2073", MODE = "0666" -SUBSYSTEM == "usb", ATTRS{idVendor} == "04f9", ATTRS{idProduct} == "2074", MODE = "0666" -SUBSYSTEM == "usb", ATTRS{idVendor} == "04f9", ATTRS{idProduct} == "20af", MODE = "0666" -SUBSYSTEM == "usb", ATTRS{idVendor} == "04f9", ATTRS{idProduct} == "20df", MODE = "0666" -SUBSYSTEM == "usb", ATTRS{idVendor} == "04f9", ATTRS{idProduct} == "20e0", MODE = "0666" -SUBSYSTEM == "usb", ATTRS{idVendor} == "04f9", ATTRS{idProduct} == "20e1", MODE = "0666" +SUBSYSTEM == "usb", ATTRS{idVendor} == "04f9", ATTRS{idProduct} == "2007", MODE="0660", TAG+="uaccess" +SUBSYSTEM == "usb", ATTRS{idVendor} == "04f9", ATTRS{idProduct} == "2011", MODE="0660", TAG+="uaccess" +SUBSYSTEM == "usb", ATTRS{idVendor} == "04f9", ATTRS{idProduct} == "2019", MODE="0660", TAG+="uaccess" +SUBSYSTEM == "usb", ATTRS{idVendor} == "04f9", ATTRS{idProduct} == "201f", MODE="0660", TAG+="uaccess" +SUBSYSTEM == "usb", ATTRS{idVendor} == "04f9", ATTRS{idProduct} == "202c", MODE="0660", TAG+="uaccess" +SUBSYSTEM == "usb", ATTRS{idVendor} == "04f9", ATTRS{idProduct} == "202d", MODE="0660", TAG+="uaccess" +SUBSYSTEM == "usb", ATTRS{idVendor} == "04f9", ATTRS{idProduct} == "2041", MODE="0660", TAG+="uaccess" +SUBSYSTEM == "usb", ATTRS{idVendor} == "04f9", ATTRS{idProduct} == "205e", MODE="0660", TAG+="uaccess" +SUBSYSTEM == "usb", ATTRS{idVendor} == "04f9", ATTRS{idProduct} == "205f", MODE="0660", TAG+="uaccess" +SUBSYSTEM == "usb", ATTRS{idVendor} == "04f9", ATTRS{idProduct} == "2061", MODE="0660", TAG+="uaccess" +SUBSYSTEM == "usb", ATTRS{idVendor} == "04f9", ATTRS{idProduct} == "2062", MODE="0660", TAG+="uaccess" +SUBSYSTEM == "usb", ATTRS{idVendor} == "04f9", ATTRS{idProduct} == "2073", MODE="0660", TAG+="uaccess" +SUBSYSTEM == "usb", ATTRS{idVendor} == "04f9", ATTRS{idProduct} == "2074", MODE="0660", TAG+="uaccess" +SUBSYSTEM == "usb", ATTRS{idVendor} == "04f9", ATTRS{idProduct} == "20af", MODE="0660", TAG+="uaccess" +SUBSYSTEM == "usb", ATTRS{idVendor} == "04f9", ATTRS{idProduct} == "20df", MODE="0660", TAG+="uaccess" +SUBSYSTEM == "usb", ATTRS{idVendor} == "04f9", ATTRS{idProduct} == "20e0", MODE="0660", TAG+="uaccess" +SUBSYSTEM == "usb", ATTRS{idVendor} == "04f9", ATTRS{idProduct} == "20e1", MODE="0660", TAG+="uaccess" From bc7d32a6e684b7851658d0ec38ac86814c725322 Mon Sep 17 00:00:00 2001 From: Jan Baier Date: Wed, 14 Aug 2024 14:12:31 +0200 Subject: [PATCH 25/53] Fix segfault when using --force-tape-width without printer When force_tape_width is *not* used it is expected to open/close the usb device. --- src/ptouch-print.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ptouch-print.c b/src/ptouch-print.c index 600261a..6c382af 100644 --- a/src/ptouch-print.c +++ b/src/ptouch-print.c @@ -648,7 +648,7 @@ int main(int argc, char *argv[]) if (im != NULL) { gdImageDestroy(im); } - if (forced_tape_width > 0) { + if (!forced_tape_width) { ptouch_close(ptdev); } libusb_exit(NULL); From 740b20e150e030aa2e75086d1202064f9c4c4090 Mon Sep 17 00:00:00 2001 From: Dominic Radermacher Date: Sun, 6 Oct 2024 17:46:29 +0200 Subject: [PATCH 26/53] Add --copies switch for multiple printouts (thanks to Wojciech Fred) --- src/libptouch.c | 4 ++-- src/ptouch-print.c | 29 ++++++++++++++++++++--------- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/src/libptouch.c b/src/libptouch.c index d20ea5d..4310360 100644 --- a/src/libptouch.c +++ b/src/libptouch.c @@ -21,7 +21,7 @@ #include #include /* malloc() */ -#include /* memcmp() */ +#include /* memcmp() */ #include /* open() */ #include /* open() */ #include /* open() */ @@ -78,7 +78,7 @@ struct _pt_dev_info ptdevs[] = { cutting of tape, printing maximum of 73mm length) */ {0x04f9, 0x20e1, "PT-D610BT", 128, 180, FLAG_P700_INIT|FLAG_USE_INFO_CMD|FLAG_HAS_PRECUT|FLAG_D460BT_MAGIC}, //{0x04f9, 0x200d, "PT-3600", 384, 360, FLAG_RASTER_PACKBITS}, - {0x04f9, 0x20af, "PT-P710BT", 128, 180, FLAG_RASTER_PACKBITS}, + {0x04f9, 0x20af, "PT-P710BT", 128, 180, FLAG_RASTER_PACKBITS|FLAG_HAS_PRECUT}, {0,0,"",0,0,0} }; diff --git a/src/ptouch-print.c b/src/ptouch-print.c index 6c382af..b05eb05 100644 --- a/src/ptouch-print.c +++ b/src/ptouch-print.c @@ -91,15 +91,15 @@ int print_img(ptouch_dev ptdev, gdImage *im, int chain) printf(_("maximum printing width for this tape is %ipx\n"), tape_width); return -1; } - //offset=64-(gdImageSY(im)/2); /* always print centered */ + //offset=64-(gdImageSY(im)/2); /* always print centered */ size_t max_pixels=ptouch_get_max_width(ptdev); - offset=((int)max_pixels / 2)-(gdImageSY(im)/2); /* always print centered */ + offset=((int)max_pixels / 2)-(gdImageSY(im)/2); /* always print centered */ printf("max_pixels=%ld, offset=%d\n", max_pixels, offset); if ((ptdev->devinfo->flags & FLAG_RASTER_PACKBITS) == FLAG_RASTER_PACKBITS) { if (debug) { printf("enable PackBits mode\n"); } - ptouch_enable_packbits(ptdev); + ptouch_enable_packbits(ptdev); } if (ptouch_rasterstart(ptdev) != 0) { printf(_("ptouch_rasterstart() failed\n")); @@ -163,7 +163,7 @@ gdImage *image_load(const char *file) } else { f = fopen(file, "rb"); } - if (f == NULL) { /* error could not open file */ + if (f == NULL) { /* error could not open file */ return NULL; } if (fseek(f, 0L, SEEK_SET)) { /* file is not seekable. eg 'stdin' */ @@ -431,6 +431,7 @@ void usage(char *progname) printf("\t--writepng \tinstead of printing, write output to png file\n"); printf("\t--force-tape-width \tSet tape width in pixels, use together with\n"); printf("\t\t\t\t--writepng without a printer connected.\n"); + printf("\t--copies \tSets the number of identical prints\n"); printf("print commands:\n"); printf("\t--image \t\tprint the given image which must be a 2 color\n"); printf("\t\t\t\t(black/white) png\n"); @@ -487,6 +488,12 @@ int parse_args(int argc, char **argv) debug=true; } else if (strcmp(&argv[i][1], "-info") == 0) { continue; /* not done here */ + } else if (strcmp(&argv[i][1], "-copies") == 0) { + if (i+1 Date: Tue, 29 Oct 2024 20:21:48 +0100 Subject: [PATCH 27/53] zero-initialise array to silence valgrind --- src/libptouch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libptouch.c b/src/libptouch.c index 4310360..e70bfbf 100644 --- a/src/libptouch.c +++ b/src/libptouch.c @@ -316,7 +316,7 @@ void ptouch_rawstatus(uint8_t raw[32]) int ptouch_getstatus(ptouch_dev ptdev) { char cmd[]="\x1biS"; /* 1B 69 53 = ESC i S = Status info request */ - uint8_t buf[32]; + uint8_t buf[32] = {}; int i, r, tx=0, tries=0; struct timespec w; From ec923ed5790bf56ad8d5adaf19586f7f492d02a5 Mon Sep 17 00:00:00 2001 From: Dominic Radermacher Date: Mon, 12 May 2025 17:47:00 +0200 Subject: [PATCH 28/53] Add support for PT-2300 and fix 112px width centering (thanks to Bradley Erickson) --- src/libptouch.c | 5 +++-- src/ptouch-print.c | 8 ++++---- udev/90-usb-ptouch-permissions.rules | 1 + 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/libptouch.c b/src/libptouch.c index e70bfbf..9876f3a 100644 --- a/src/libptouch.c +++ b/src/libptouch.c @@ -1,7 +1,7 @@ /* libptouch - functions to help accessing a brother ptouch - Copyright (C) 2013-2023 Dominic Radermacher + Copyright (C) 2013-2025 Dominic Radermacher This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 3 as @@ -45,9 +45,10 @@ struct _pt_tape_info tape_info[]= { }; struct _pt_dev_info ptdevs[] = { + {0x04f9, 0x2004, "PT-2300", 112, 180, FLAG_RASTER_PACKBITS|FLAG_HAS_PRECUT}, /* 180dpi, 112px printhead */ {0x04f9, 0x2007, "PT-2420PC", 128, 180, FLAG_RASTER_PACKBITS}, /* 180dpi, 128px, maximum tape width 24mm, must send TIFF compressed pixel data */ {0x04f9, 0x2011, "PT-2450PC", 128, 180, FLAG_RASTER_PACKBITS}, - {0x04f9, 0x2019, "PT-1950", 128, 180, FLAG_RASTER_PACKBITS}, /* 180dpi, apparently 112px printhead ?, maximum tape width 18mm - unconfirmed if it works */ + {0x04f9, 0x2019, "PT-1950", 112, 180, FLAG_RASTER_PACKBITS}, /* 180dpi, apparently 112px printhead ?, maximum tape width 18mm - unconfirmed if it works */ {0x04f9, 0x201f, "PT-2700", 128, 180, FLAG_HAS_PRECUT}, {0x04f9, 0x202c, "PT-1230PC", 128, 180, FLAG_NONE}, /* 180dpi, supports tapes up to 12mm - I don't know how much pixels it can print! */ /* Notes about the PT-1230PC: While it is true that this printer supports diff --git a/src/ptouch-print.c b/src/ptouch-print.c index b05eb05..b742596 100644 --- a/src/ptouch-print.c +++ b/src/ptouch-print.c @@ -1,7 +1,7 @@ /* ptouch-print - Print labels with images or text on a Brother P-Touch - Copyright (C) 2015-2024 Dominic Radermacher + Copyright (C) 2015-2025 Dominic Radermacher This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 3 as @@ -67,7 +67,7 @@ void rasterline_setpixel(uint8_t* rasterline, size_t size, int pixel) { // TODO: pixel should be unsigned, since we can't have negative // if (pixel > ptdev->devinfo->device_max_px) { - if (pixel > (int)(size*8)) { + if ((pixel < 0) || (pixel >= (int)(size*8))) { return; } rasterline[(size-1)-(pixel/8)] |= (uint8_t)(1<<(pixel%8)); @@ -91,7 +91,7 @@ int print_img(ptouch_dev ptdev, gdImage *im, int chain) printf(_("maximum printing width for this tape is %ipx\n"), tape_width); return -1; } - //offset=64-(gdImageSY(im)/2); /* always print centered */ + printf(_("image size (%ipx x %ipx)\n"), gdImageSX(im), gdImageSY(im)); size_t max_pixels=ptouch_get_max_width(ptdev); offset=((int)max_pixels / 2)-(gdImageSY(im)/2); /* always print centered */ printf("max_pixels=%ld, offset=%d\n", max_pixels, offset); @@ -136,7 +136,7 @@ int print_img(ptouch_dev ptdev, gdImage *im, int chain) rasterline_setpixel(rasterline, sizeof(rasterline), offset+i); } } - if (ptouch_sendraster(ptdev, rasterline, 16) != 0) { + if (ptouch_sendraster(ptdev, rasterline, (ptdev->devinfo->max_px / 8)) != 0) { printf(_("ptouch_sendraster() failed\n")); return -1; } diff --git a/udev/90-usb-ptouch-permissions.rules b/udev/90-usb-ptouch-permissions.rules index b9d9f66..1c379f8 100644 --- a/udev/90-usb-ptouch-permissions.rules +++ b/udev/90-usb-ptouch-permissions.rules @@ -1,4 +1,5 @@ # Enable non-root access for known ptouch printers +SUBSYSTEM == "usb", ATTRS{idVendor} == "04f9", ATTRS{idProduct} == "2004", MODE="0660", TAG+="uaccess" SUBSYSTEM == "usb", ATTRS{idVendor} == "04f9", ATTRS{idProduct} == "2007", MODE="0660", TAG+="uaccess" SUBSYSTEM == "usb", ATTRS{idVendor} == "04f9", ATTRS{idProduct} == "2011", MODE="0660", TAG+="uaccess" SUBSYSTEM == "usb", ATTRS{idVendor} == "04f9", ATTRS{idProduct} == "2019", MODE="0660", TAG+="uaccess" From a6c67df2c9a0f601188ee04460124b20e1f90c33 Mon Sep 17 00:00:00 2001 From: Dominic Radermacher Date: Mon, 12 May 2025 17:59:45 +0200 Subject: [PATCH 29/53] cosmetics --- src/ptouch-print.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/ptouch-print.c b/src/ptouch-print.c index b742596..9a1bf30 100644 --- a/src/ptouch-print.c +++ b/src/ptouch-print.c @@ -76,24 +76,23 @@ void rasterline_setpixel(uint8_t* rasterline, size_t size, int pixel) int print_img(ptouch_dev ptdev, gdImage *im, int chain) { - int d,i,k,offset,tape_width; uint8_t rasterline[(ptdev->devinfo->max_px)/8]; if (!im) { printf(_("nothing to print\n")); return -1; } - tape_width=ptouch_get_tape_width(ptdev); + int tape_width = ptouch_get_tape_width(ptdev); + size_t max_pixels = ptouch_get_max_width(ptdev); /* find out whether color 0 or color 1 is darker */ - d=(gdImageRed(im,1)+gdImageGreen(im,1)+gdImageBlue(im,1) < gdImageRed(im,0)+gdImageGreen(im,0)+gdImageBlue(im,0))?1:0; + int d = (gdImageRed(im,1) + gdImageGreen(im,1) + gdImageBlue(im,1) < gdImageRed(im,0) + gdImageGreen(im,0) + gdImageBlue(im,0))?1:0; if (gdImageSY(im) > tape_width) { printf(_("image is too large (%ipx x %ipx)\n"), gdImageSX(im), gdImageSY(im)); printf(_("maximum printing width for this tape is %ipx\n"), tape_width); return -1; } printf(_("image size (%ipx x %ipx)\n"), gdImageSX(im), gdImageSY(im)); - size_t max_pixels=ptouch_get_max_width(ptdev); - offset=((int)max_pixels / 2)-(gdImageSY(im)/2); /* always print centered */ + int offset = ((int)max_pixels / 2) - (gdImageSY(im)/2); /* always print centered */ printf("max_pixels=%ld, offset=%d\n", max_pixels, offset); if ((ptdev->devinfo->flags & FLAG_RASTER_PACKBITS) == FLAG_RASTER_PACKBITS) { if (debug) { @@ -129,10 +128,10 @@ int print_img(ptouch_dev ptdev, gdImage *im, int chain) printf(_("send precut command\n")); } } - for (k=0; k Date: Mon, 12 May 2025 18:29:56 +0200 Subject: [PATCH 30/53] for printers with less than 128px printhead, make sure we dont print too much pixels --- src/ptouch-print.c | 207 +++++++++++++++++++++++---------------------- 1 file changed, 106 insertions(+), 101 deletions(-) diff --git a/src/ptouch-print.c b/src/ptouch-print.c index 9a1bf30..7ee1bfd 100644 --- a/src/ptouch-print.c +++ b/src/ptouch-print.c @@ -44,8 +44,8 @@ int needed_width(char *text, char *font, int fsz); int print_img(ptouch_dev ptdev, gdImage *im, int chain); int write_png(gdImage *im, const char *file); gdImage *img_append(gdImage *in_1, gdImage *in_2); -gdImage *img_cutmark(int tape_width); -gdImage *render_text(char *font, char *line[], int lines, int tape_width); +gdImage *img_cutmark(int print_width); +gdImage *render_text(char *font, char *line[], int lines, int print_width); void unsupported_printer(ptouch_dev ptdev); void usage(char *progname); int parse_args(int argc, char **argv); @@ -58,7 +58,7 @@ int verbose = 0; int fontsize = 0; bool debug = false; bool chain = false; -int forced_tape_width = 0; +int forced_print_width = 0; /* -------------------------------------------------------------------- -------------------------------------------------------------------- */ @@ -152,10 +152,10 @@ int print_img(ptouch_dev ptdev, gdImage *im, int chain) gdImage *image_load(const char *file) { - const uint8_t png[8]={0x89,'P','N','G',0x0d,0x0a,0x1a,0x0a}; + const uint8_t png[8] = {0x89,'P','N','G',0x0d,0x0a,0x1a,0x0a}; char d[10]; FILE *f; - gdImage *img=NULL; + gdImage *img = NULL; if (!strcmp(file, "-")) { f = stdin; @@ -166,14 +166,14 @@ gdImage *image_load(const char *file) return NULL; } if (fseek(f, 0L, SEEK_SET)) { /* file is not seekable. eg 'stdin' */ - img=gdImageCreateFromPng(f); + img = gdImageCreateFromPng(f); } else { if (fread(d, sizeof(d), 1, f) != 1) { return NULL; } rewind(f); if (memcmp(d, png, 8) == 0) { - img=gdImageCreateFromPng(f); + img = gdImageCreateFromPng(f); } } fclose(f); @@ -200,14 +200,12 @@ int write_png(gdImage *im, const char *file) int get_baselineoffset(char *text, char *font, int fsz) { int brect[8]; - int o_offset; - int text_offset; /* NOTE: This assumes that 'o' is always on the baseline */ gdImageStringFT(NULL, &brect[0], -1, font, fsz, 0.0, 0, 0, "o"); - o_offset=brect[1]; + int o_offset = brect[1]; gdImageStringFT(NULL, &brect[0], -1, font, fsz, 0.0, 0, 0, text); - text_offset=brect[1]; + int text_offset = brect[1]; if (debug) { printf(_("debug: o baseline offset - %d\n"), o_offset); printf(_("debug: text baseline offset - %d\n"), text_offset); @@ -222,7 +220,7 @@ int get_baselineoffset(char *text, char *font, int fsz) -------------------------------------------------------------------- */ int find_fontsize(int want_px, char *font, char *text) { - int save=0; + int save = 0; int brect[8]; for (int i=4; ; ++i) { @@ -230,7 +228,7 @@ int find_fontsize(int want_px, char *font, char *text) break; } if (brect[1]-brect[5] <= want_px) { - save=i; + save = i; } else { break; } @@ -261,12 +259,12 @@ int offset_x(char *text, char *font, int fsz) return -brect[0]; } -gdImage *render_text(char *font, char *line[], int lines, int tape_width) +gdImage *render_text(char *font, char *line[], int lines, int print_width) { int brect[8]; - int i, black, x=0, tmp=0, fsz=0; + int i, black, x = 0, tmp = 0, fsz = 0; char *p; - gdImage *im=NULL; + gdImage *im = NULL; if (debug) { printf(_("render_text(): %i lines, font = '%s'\n"), lines, font); @@ -275,11 +273,11 @@ gdImage *render_text(char *font, char *line[], int lines, int tape_width) printf(_("warning: font config not available\n")); } if (fontsize > 0) { - fsz=fontsize; + fsz = fontsize; printf(_("setting font size=%i\n"), fsz); } else { - for (i=0; i x) { - x=tmp; + x = tmp; } } - im=gdImageCreatePalette(x, tape_width); + im = gdImageCreatePalette(x, print_width); gdImageColorAllocate(im, 255, 255, 255); - black=gdImageColorAllocate(im, 0, 0, 0); + black = gdImageColorAllocate(im, 0, 0, 0); /* gdImageStringFT(im,brect,fg,fontlist,size,angle,x,y,string) */ /* find max needed line height for ALL lines */ int max_height=0; - for (i=0; i max_height) { - max_height=lineheight; + max_height = lineheight; } } if (debug) { printf("debug: needed (max) height is %ipx\n", max_height); } - if ((max_height * lines) > tape_width) { + if ((max_height * lines) > print_width) { printf("Font size %d too large for %d lines\n", fsz, lines); return NULL; } /* calculate unused pixels */ - int unused_px = tape_width - (max_height * lines); + int unused_px = print_width - (max_height * lines); /* now render lines */ - for (i=0; i width) { - width=gdImageSY(in_2); + width = gdImageSY(in_2); } } if ((width == 0) || (length == 0)) { return NULL; } - out=gdImageCreatePalette(length, width); + out = gdImageCreatePalette(length, width); if (out == NULL) { return NULL; } @@ -383,36 +381,36 @@ gdImage *img_append(gdImage *in_1, gdImage *in_2) return out; } -gdImage *img_cutmark(int tape_width) +gdImage *img_cutmark(int print_width) { - gdImage *out=NULL; + gdImage *out = NULL; int style_dashed[6]; - out=gdImageCreatePalette(9, tape_width); + out = gdImageCreatePalette(9, print_width); if (out == NULL) { return NULL; } gdImageColorAllocate(out, 255, 255, 255); - int black=gdImageColorAllocate(out, 0, 0, 0); - style_dashed[0]=gdTransparent; - style_dashed[1]=gdTransparent; - style_dashed[2]=gdTransparent; - style_dashed[3]=black; - style_dashed[4]=black; - style_dashed[5]=black; + int black = gdImageColorAllocate(out, 0, 0, 0); + style_dashed[0] = gdTransparent; + style_dashed[1] = gdTransparent; + style_dashed[2] = gdTransparent; + style_dashed[3] = black; + style_dashed[4] = black; + style_dashed[5] = black; gdImageSetStyle(out, style_dashed, 6); - gdImageLine(out, 5, 0, 5, tape_width-1, gdStyled); + gdImageLine(out, 5, 0, 5, print_width - 1, gdStyled); return out; } -gdImage *img_padding(int tape_width, int length) +gdImage *img_padding(int print_width, int length) { - gdImage *out=NULL; + gdImage *out = NULL; if ((length < 1) || (length > 256)) { length=1; } - out=gdImageCreatePalette(length, tape_width); + out = gdImageCreatePalette(length, print_width); if (out == NULL) { return NULL; } @@ -451,62 +449,62 @@ int parse_args(int argc, char **argv) { int lines, i; - for (i=1; i= argc) || (argv[i+1][0] == '-')) { break; } @@ -522,28 +520,30 @@ int parse_args(int argc, char **argv) usage(argv[0]); } } - if (forced_tape_width && !save_png) { - forced_tape_width = 0; + if (forced_print_width && !save_png) { + forced_print_width = 0; } return i; } int main(int argc, char *argv[]) { - int i, lines = 0, tape_width, copies=1; + int i, lines = 0, copies = 1, print_width = 0; char *line[MAX_LINES]; - gdImage *im=NULL; - gdImage *out=NULL; - ptouch_dev ptdev=NULL; + gdImage *im = NULL; + gdImage *out = NULL; + ptouch_dev ptdev = NULL; setlocale(LC_ALL, ""); bindtextdomain("ptouch-print", "/usr/share/locale/"); textdomain("ptouch-print"); - i=parse_args(argc, argv); + i = parse_args(argc, argv); if (i != argc) { usage(argv[0]); } - if (!forced_tape_width) { + int tape_width = ptouch_get_tape_width(ptdev); + int max_print_width = ptouch_get_max_width(ptdev); + if (!forced_print_width) { if ((ptouch_open(&ptdev)) < 0) { return 5; } @@ -554,28 +554,32 @@ int main(int argc, char *argv[]) printf(_("ptouch_getstatus() failed\n")); return 1; } - tape_width=ptouch_get_tape_width(ptdev); + print_width = tape_width; } else { - tape_width = forced_tape_width; + print_width = forced_print_width; } - for (i=1; i max_print_width) { + print_width = max_print_width; + } + for (i = 1; i < argc; ++i) { if (*argv[i] != '-') { break; } if (strcmp(&argv[i][1], "-font") == 0) { - if (i+1status->media_type, pt_mediatype(ptdev->status->media_type)); printf("media width = %d mm\n", ptdev->status->media_width); @@ -596,39 +601,39 @@ int main(int argc, char *argv[]) } exit(0); } else if (strcmp(&argv[i][1], "-image") == 0) { - if ((im=image_load(argv[++i])) == NULL) { + if ((im = image_load(argv[++i])) == NULL) { printf(_("failed to load image file\n")); return 1; } - out=img_append(out, im); + out = img_append(out, im); gdImageDestroy(im); im = NULL; } else if (strcmp(&argv[i][1], "-text") == 0) { - for (lines=0; (lines < MAX_LINES) && (i < argc); ++lines) { + for (lines = 0; (lines < MAX_LINES) && (i < argc); ++lines) { if ((i+1 >= argc) || (argv[i+1][0] == '-')) { break; } ++i; - line[lines]=argv[i]; + line[lines] = argv[i]; } if (lines) { - if ((im=render_text(font_file, line, lines, tape_width)) == NULL) { + if ((im = render_text(font_file, line, lines, print_width)) == NULL) { printf(_("could not render text\n")); return 1; } - out=img_append(out, im); + out = img_append(out, im); gdImageDestroy(im); im = NULL; } } else if (strcmp(&argv[i][1], "-cutmark") == 0) { - im=img_cutmark(tape_width); - out=img_append(out, im); + im = img_cutmark(print_width); + out = img_append(out, im); gdImageDestroy(im); im = NULL; } else if (strcmp(&argv[i][1], "-pad") == 0) { int length=strtol(argv[++i], NULL, 10); - im=img_padding(tape_width, length); - out=img_append(out, im); + im = img_padding(print_width, length); + out = img_append(out, im); gdImageDestroy(im); im = NULL; } else if (strcmp(&argv[i][1], "-chain") == 0) { @@ -645,7 +650,7 @@ int main(int argc, char *argv[]) if (save_png) { write_png(out, save_png); } else { - for (i=0; i Date: Mon, 19 May 2025 13:33:55 +0200 Subject: [PATCH 31/53] fix segfault for last commit --- src/libptouch.c | 40 +++++++++++++++++++++++++++++++++++++++- src/ptouch-print.c | 39 +++++++++++++++++++-------------------- 2 files changed, 58 insertions(+), 21 deletions(-) diff --git a/src/libptouch.c b/src/libptouch.c index 9876f3a..eed8e97 100644 --- a/src/libptouch.c +++ b/src/libptouch.c @@ -163,6 +163,9 @@ int ptouch_open(ptouch_dev *ptdev) int ptouch_close(ptouch_dev ptdev) { + if (!ptdev) { + return -1; + } libusb_release_interface(ptdev->h, 0); libusb_close(ptdev->h); return 0; @@ -172,7 +175,11 @@ int ptouch_send(ptouch_dev ptdev, uint8_t *data, size_t len) { int r, tx; - if ((ptdev == NULL) || (len > 128)) { + if (!ptdev) { + fprintf(stderr, _("debug: called ptouch_send() with NULL ptdev\n")); + return -1; + } + if (len > 128) { return -1; } if ((r=libusb_bulk_transfer(ptdev->h, 0x02, data, (int)len, &tx, 0)) != 0) { @@ -228,6 +235,11 @@ int ptouch_enable_packbits(ptouch_dev ptdev) /* print information command */ int ptouch_info_cmd(ptouch_dev ptdev, int size_x) { + if (!ptdev) { + fprintf(stderr, _("debug: called ptouch_info_cmd() with NULL ptdev\n")); + return -1; + } + /* 1B 69 7A {n1} {n2} {n3} {n4} {n5} {n6} {n7} {n8} {n9} {n10} */ uint8_t cmd[] = "\x1b\x69\x7a\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"; @@ -265,6 +277,10 @@ int ptouch_send_precut_cmd(ptouch_dev ptdev, int precut) int ptouch_rasterstart(ptouch_dev ptdev) { + if (!ptdev) { + fprintf(stderr, _("debug: called ptouch_rasterstart() with NULL ptdev\n")); + return -1; + } /* 1B 69 52 01 = Select graphics transfer mode = Raster */ char cmd[] = "\x1b\x69\x52\x01"; /* 1B 69 61 01 = switch mode (0=esc/p, 1=raster mode) */ @@ -292,6 +308,11 @@ int ptouch_ff(ptouch_dev ptdev) /* finish print and either cut or leave tape in machine */ int ptouch_finalize(ptouch_dev ptdev, int chain) { + if (!ptdev) { + fprintf(stderr, _("debug: called ptouch_finalize() with NULL ptdev\n")); + return -1; + } + char cmd_eject[]="\x1a"; /* Print command with feeding */ char cmd_chain[]="\x0c"; /* Print command (no cut) */ @@ -321,6 +342,11 @@ int ptouch_getstatus(ptouch_dev ptdev) int i, r, tx=0, tries=0; struct timespec w; + if (!ptdev) { + fprintf(stderr, _("debug: called ptouch_getstatus() with NULL ptdev\n")); + return -1; + } + ptouch_send(ptdev, (uint8_t *)cmd, strlen(cmd)); while (tx == 0) { w.tv_sec=0; @@ -372,11 +398,19 @@ int ptouch_getstatus(ptouch_dev ptdev) size_t ptouch_get_tape_width(ptouch_dev ptdev) { + if (!ptdev) { + fprintf(stderr, _("debug: called ptouch_get_tape_width() with NULL ptdev\n")); + return 0; + } return ptdev->tape_width_px; } size_t ptouch_get_max_width(ptouch_dev ptdev) { + if (!ptdev) { + fprintf(stderr, _("debug: called ptouch_get_max_width() with NULL ptdev\n")); + return 0; + } return ptdev->devinfo->max_px; } @@ -385,6 +419,10 @@ int ptouch_sendraster(ptouch_dev ptdev, uint8_t *data, size_t len) uint8_t buf[64]; int rc; + if (!ptdev) { + fprintf(stderr, _("debug: called ptouch_sendraster() with NULL ptdev\n")); + return -1; + } if (len > (size_t)(ptdev->devinfo->max_px / 8)) { return -1; } diff --git a/src/ptouch-print.c b/src/ptouch-print.c index 7ee1bfd..2a40e94 100644 --- a/src/ptouch-print.c +++ b/src/ptouch-print.c @@ -58,7 +58,7 @@ int verbose = 0; int fontsize = 0; bool debug = false; bool chain = false; -int forced_print_width = 0; +int forced_tape_width = 0; /* -------------------------------------------------------------------- -------------------------------------------------------------------- */ @@ -473,7 +473,7 @@ int parse_args(int argc, char **argv) } } else if (strcmp(&argv[i][1], "-force-tape-width") == 0) { if (i+1 < argc) { - forced_print_width = strtol(argv[++i], NULL, 10); + forced_tape_width = strtol(argv[++i], NULL, 10); } else { usage(argv[0]); } @@ -520,15 +520,15 @@ int parse_args(int argc, char **argv) usage(argv[0]); } } - if (forced_print_width && !save_png) { - forced_print_width = 0; + if (forced_tape_width && !save_png) { + forced_tape_width = 0; } return i; } int main(int argc, char *argv[]) { - int i, lines = 0, copies = 1, print_width = 0; + int lines = 0, copies = 1, print_width = 0; char *line[MAX_LINES]; gdImage *im = NULL; gdImage *out = NULL; @@ -537,13 +537,11 @@ int main(int argc, char *argv[]) setlocale(LC_ALL, ""); bindtextdomain("ptouch-print", "/usr/share/locale/"); textdomain("ptouch-print"); - i = parse_args(argc, argv); + int i = parse_args(argc, argv); if (i != argc) { usage(argv[0]); } - int tape_width = ptouch_get_tape_width(ptdev); - int max_print_width = ptouch_get_max_width(ptdev); - if (!forced_print_width) { + if (!forced_tape_width) { if ((ptouch_open(&ptdev)) < 0) { return 5; } @@ -554,13 +552,14 @@ int main(int argc, char *argv[]) printf(_("ptouch_getstatus() failed\n")); return 1; } - print_width = tape_width; - } else { - print_width = forced_print_width; - } - // do not try to print more pixels than printhead has - if (print_width > max_print_width) { - print_width = max_print_width; + print_width = ptouch_get_tape_width(ptdev); + int max_print_width = ptouch_get_max_width(ptdev); + // do not try to print more pixels than printhead has + if (print_width > max_print_width) { + print_width = max_print_width; + } + } else { // --forced_tape_width together with --writepng + print_width = forced_tape_width; } for (i = 1; i < argc; ++i) { if (*argv[i] != '-') { @@ -579,7 +578,7 @@ int main(int argc, char *argv[]) usage(argv[0]); } } else if (strcmp(&argv[i][1], "-force-tape-width") == 0) { - if (forced_print_width && save_png) { + if (forced_tape_width && save_png) { ++i; continue; } else { @@ -589,8 +588,8 @@ int main(int argc, char *argv[]) i++; continue; } else if (strcmp(&argv[i][1], "-info") == 0) { - printf(_("maximum printing width for this printer is %ipx\n"), max_print_width); - printf(_("maximum printing width for this tape is %ipx\n"), tape_width); + printf(_("maximum printing width for this printer is %ldpx\n"), ptouch_get_max_width(ptdev)); + printf(_("maximum printing width for this tape is %ldpx\n"), ptouch_get_tape_width(ptdev)); printf("media type = %02x (%s)\n", ptdev->status->media_type, pt_mediatype(ptdev->status->media_type)); printf("media width = %d mm\n", ptdev->status->media_width); printf("tape color = %02x (%s)\n", ptdev->status->tape_color, pt_tapecolor(ptdev->status->tape_color)); @@ -663,7 +662,7 @@ int main(int argc, char *argv[]) if (im != NULL) { gdImageDestroy(im); } - if (!forced_print_width) { + if (!forced_tape_width) { ptouch_close(ptdev); } libusb_exit(NULL); From 2c9828af872d13cf521a525347b941b03e26d332 Mon Sep 17 00:00:00 2001 From: Dominic Radermacher Date: Sun, 1 Jun 2025 20:12:20 +0200 Subject: [PATCH 32/53] add support for PT-9200DX, thanks Ralf Lieb for reporting --- src/libptouch.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libptouch.c b/src/libptouch.c index eed8e97..294d921 100644 --- a/src/libptouch.c +++ b/src/libptouch.c @@ -45,6 +45,7 @@ struct _pt_tape_info tape_info[]= { }; struct _pt_dev_info ptdevs[] = { + {0x04f9, 0x2001, "PT-9200DX", 384, 360, FLAG_RASTER_PACKBITS|FLAG_HAS_PRECUT}, /* 360dpi, maximum 128px, max tape width 36mm */ {0x04f9, 0x2004, "PT-2300", 112, 180, FLAG_RASTER_PACKBITS|FLAG_HAS_PRECUT}, /* 180dpi, 112px printhead */ {0x04f9, 0x2007, "PT-2420PC", 128, 180, FLAG_RASTER_PACKBITS}, /* 180dpi, 128px, maximum tape width 24mm, must send TIFF compressed pixel data */ {0x04f9, 0x2011, "PT-2450PC", 128, 180, FLAG_RASTER_PACKBITS}, From 1a39fe1284e662c86f0caa8760be659e09debac7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcus=20M=C3=BCller?= Date: Sat, 31 May 2025 22:22:53 +0200 Subject: [PATCH 33/53] udev uaccess rules must have lower order than 73-seat-late.rules MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit see, for example, https://github.com/bigbigmdm/IMSProg/issues/98 . If the rule granting uaccess tag to a device is loaded after the seat-late rule, seat-late can't grant the user access to the device. Signed-off-by: Marcus Müller --- CMakeLists.txt | 2 +- ...ptouch-permissions.rules => 20-usb-ptouch-permissions.rules} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename udev/{90-usb-ptouch-permissions.rules => 20-usb-ptouch-permissions.rules} (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 38741ee..fd5a3bb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -71,6 +71,6 @@ install(TARGETS ${PROJECT_NAME} DESTINATION bin) install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/ptouch-print.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1) if(EXISTS /etc/udev/rules.d) - install(FILES udev/90-usb-ptouch-permissions.rules DESTINATION /etc/udev/rules.d) + install(FILES udev/20-usb-ptouch-permissions.rules DESTINATION /etc/udev/rules.d) install(CODE "execute_process(COMMAND udevadm control --reload-rules)") endif() diff --git a/udev/90-usb-ptouch-permissions.rules b/udev/20-usb-ptouch-permissions.rules similarity index 100% rename from udev/90-usb-ptouch-permissions.rules rename to udev/20-usb-ptouch-permissions.rules From 1f450d91249ba0c3673e4dbfe5fc68c059a863a8 Mon Sep 17 00:00:00 2001 From: Dominic Radermacher Date: Sun, 22 Jun 2025 08:13:08 +0200 Subject: [PATCH 34/53] Add support for PT-E310BT (thanks to Christian Radin) --- src/libptouch.c | 5 +++++ udev/20-usb-ptouch-permissions.rules | 1 + 2 files changed, 6 insertions(+) diff --git a/src/libptouch.c b/src/libptouch.c index 294d921..46006f4 100644 --- a/src/libptouch.c +++ b/src/libptouch.c @@ -81,6 +81,11 @@ struct _pt_dev_info ptdevs[] = { {0x04f9, 0x20e1, "PT-D610BT", 128, 180, FLAG_P700_INIT|FLAG_USE_INFO_CMD|FLAG_HAS_PRECUT|FLAG_D460BT_MAGIC}, //{0x04f9, 0x200d, "PT-3600", 384, 360, FLAG_RASTER_PACKBITS}, {0x04f9, 0x20af, "PT-P710BT", 128, 180, FLAG_RASTER_PACKBITS|FLAG_HAS_PRECUT}, + /* added by Christian, PT-E310BT (aka PT-E310BTVP) requires these flags, otherwise not returning from libusb_bulk_transfer-call */ + /* printhead 128px, 180 dpi resolution */ + /* 3,5/6/9/12/18 mm TZe Tapes, 12mm and 18mm tested */ + /* 5,2/9/11,2 mm HSe heat shrink tubes not tested, probably requiring extension of struct _pt_tape_info */ + {0x04f9, 0x2201, "PT-E310BT", 128, 180, FLAG_P700_INIT|FLAG_USE_INFO_CMD|FLAG_D460BT_MAGIC}, {0,0,"",0,0,0} }; diff --git a/udev/20-usb-ptouch-permissions.rules b/udev/20-usb-ptouch-permissions.rules index 1c379f8..d891b1a 100644 --- a/udev/20-usb-ptouch-permissions.rules +++ b/udev/20-usb-ptouch-permissions.rules @@ -17,3 +17,4 @@ SUBSYSTEM == "usb", ATTRS{idVendor} == "04f9", ATTRS{idProduct} == "20af", MODE= SUBSYSTEM == "usb", ATTRS{idVendor} == "04f9", ATTRS{idProduct} == "20df", MODE="0660", TAG+="uaccess" SUBSYSTEM == "usb", ATTRS{idVendor} == "04f9", ATTRS{idProduct} == "20e0", MODE="0660", TAG+="uaccess" SUBSYSTEM == "usb", ATTRS{idVendor} == "04f9", ATTRS{idProduct} == "20e1", MODE="0660", TAG+="uaccess" +SUBSYSTEM == "usb", ATTRS{idVendor} == "04f9", ATTRS{idProduct} == "2201", MODE="0660", TAG+="uaccess" From efa48162a82115a287ac5fea75dd3884d669f4de Mon Sep 17 00:00:00 2001 From: Dominic Radermacher Date: Sun, 3 Aug 2025 09:42:30 +0200 Subject: [PATCH 35/53] better gettext support (thanks to Michael Schulz) --- CMakeLists.txt | 3 +- cmake/gettext.cmake | 76 +++++++++++++++++++++++++++++++++++++++++++++ po/de.po | 5 ++- po/en.po | 7 +++-- src/ptouch-print.c | 6 +++- 5 files changed, 89 insertions(+), 8 deletions(-) create mode 100644 cmake/gettext.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index fd5a3bb..61f7c40 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -37,7 +37,6 @@ target_link_libraries(${PROJECT_NAME} PRIVATE target_sources(${PROJECT_NAME} PRIVATE include/ptouch.h - include/gettext.h src/libptouch.c src/ptouch-print.c ) @@ -66,6 +65,8 @@ add_custom_target(git-version ALL ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/gitversion.cmake ) +include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/gettext.cmake) + install(TARGETS ${PROJECT_NAME} DESTINATION bin) install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/ptouch-print.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1) diff --git a/cmake/gettext.cmake b/cmake/gettext.cmake new file mode 100644 index 0000000..21d6155 --- /dev/null +++ b/cmake/gettext.cmake @@ -0,0 +1,76 @@ +# Utilize gettext multilingual internationalization services +if(Gettext_FOUND) + add_custom_target( + pot-update + ALL + DEPENDS ${CMAKE_SOURCE_DIR}/po/ptouch.pot + ) + add_dependencies(pot-update git-version) + + # generate pot files using xgettext + if(GETTEXT_XGETTEXT_EXECUTABLE) + file(GLOB_RECURSE C_FILES RELATIVE ${CMAKE_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/src/*.c) + file(STRINGS ${CMAKE_BINARY_DIR}/version.h VERSION_LINE REGEX "VERSION") + string(REGEX MATCH "\".*\"$" PVERSION ${VERSION_LINE}) + add_custom_command( + TARGET pot-update + PRE_BUILD + COMMAND ${GETTEXT_XGETTEXT_EXECUTABLE} + --keyword=_ + --keyword=N_ + --force-po + --package-name=${PROJECT_NAME} + --package-version=${PVERSION} + --copyright-holder="Dominic Radermacher " + --msgid-bugs-address="dominic@familie-radermacher.ch" + --output ${CMAKE_SOURCE_DIR}/po/ptouch.pot + ${C_FILES} + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + ) + else() + message(DEBUG "Variable GETTEXT_XGETTEXT_EXECUTABLE not set") + endif() + + # read available languages from LINGUAS file while ignoring comments + file(STRINGS po/LINGUAS LINGUAS REGEX "^[^#]") + + # merge po files + if(GETTEXT_MSGMERGE_EXECUTABLE) + add_custom_target( + po-merge + ALL + DEPENDS ${CMAKE_SOURCE_DIR}/po/ptouch.pot + ) + add_dependencies(po-merge pot-update) + + foreach(LINGUA IN LISTS LINGUAS) + add_custom_command( + TARGET po-merge + PRE_BUILD + COMMAND ${GETTEXT_MSGMERGE_EXECUTABLE} + --update + --quiet + ${CMAKE_SOURCE_DIR}/po/${LINGUA}.po + ${CMAKE_SOURCE_DIR}/po/ptouch.pot + ) + endforeach() + endif() + + # compile po files + foreach(LINGUA IN LISTS LINGUAS) + gettext_process_po_files( + ${LINGUA} + ALL + PO_FILES ${CMAKE_SOURCE_DIR}/po/${LINGUA}.po + ) + endforeach() + + # install mo files + foreach(LINGUA IN LISTS LINGUAS) + install( + FILES "${CMAKE_CURRENT_BINARY_DIR}/${LINGUA}.gmo" + DESTINATION "${CMAKE_INSTALL_LOCALEDIR}/${LINGUA}/LC_MESSAGES" + RENAME "${PROJECT_NAME}.mo" + ) + endforeach() +endif() diff --git a/po/de.po b/po/de.po index d67eab7..d544bb1 100644 --- a/po/de.po +++ b/po/de.po @@ -56,7 +56,8 @@ msgstr "" #: src/libptouch.c:158 #, c-format -msgid "No P-Touch printer found on USB (remember to put switch to position E)\n" +msgid "" +"No P-Touch printer found on USB (remember to put switch to position E)\n" msgstr "Kein P-Ptouch Drucker am USB gefunden (Schalter muss auf E stehen)\n" #: src/libptouch.c:178 @@ -66,7 +67,6 @@ msgstr "" #: src/libptouch.c:182 #, fuzzy, c-format -#| msgid "read error: got %i instead of 32 bytes\n" msgid "write error: could send only %i of %ld bytes\n" msgstr "Lesefehler: %i anstatt 32 bytes empfangen\n" @@ -152,7 +152,6 @@ msgstr "" #: src/ptouch-print.c:133 #, fuzzy, c-format -#| msgid "ptouch_send() failed\n" msgid "ptouch_sendraster() failed\n" msgstr "ptouch_send() fehlgeschlagen\n" diff --git a/po/en.po b/po/en.po index e50f765..c495d46 100644 --- a/po/en.po +++ b/po/en.po @@ -55,8 +55,10 @@ msgstr "interface claim error: %s\n" #: src/libptouch.c:158 #, c-format -msgid "No P-Touch printer found on USB (remember to put switch to position E)\n" -msgstr "No P-Touch printer found on USB (remember to put switch to position E)\n" +msgid "" +"No P-Touch printer found on USB (remember to put switch to position E)\n" +msgstr "" +"No P-Touch printer found on USB (remember to put switch to position E)\n" #: src/libptouch.c:178 #, c-format @@ -65,7 +67,6 @@ msgstr "write error: %s\n" #: src/libptouch.c:182 #, fuzzy, c-format -#| msgid "write error: could send only %i of %i bytes\n" msgid "write error: could send only %i of %ld bytes\n" msgstr "write error: could send only %i of %i bytes\n" diff --git a/src/ptouch-print.c b/src/ptouch-print.c index 2a40e94..512bfeb 100644 --- a/src/ptouch-print.c +++ b/src/ptouch-print.c @@ -535,7 +535,11 @@ int main(int argc, char *argv[]) ptouch_dev ptdev = NULL; setlocale(LC_ALL, ""); - bindtextdomain("ptouch-print", "/usr/share/locale/"); + const char *textdomain_dir = getenv("TEXTDOMAINDIR"); + if (!textdomain_dir) { + textdomain_dir = "/usr/share/locale/"; + } + bindtextdomain("ptouch-print", textdomain_dir); textdomain("ptouch-print"); int i = parse_args(argc, argv); if (i != argc) { From d1eeacbdd869a03cb32bf111bebae784b6daa3c1 Mon Sep 17 00:00:00 2001 From: Dominic Radermacher Date: Sun, 3 Aug 2025 10:11:15 +0200 Subject: [PATCH 36/53] Added USB IDs for PT-E550W, but doesn't work yet (only prints empty tape) --- src/libptouch.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/libptouch.c b/src/libptouch.c index 46006f4..4fed15f 100644 --- a/src/libptouch.c +++ b/src/libptouch.c @@ -67,6 +67,9 @@ struct _pt_dev_info ptdevs[] = { {0x04f9, 0x205f, "PT-E500", 128, 180, FLAG_RASTER_PACKBITS}, /* Note about the PT-E500: was reported by Jesse Becker with the remark that it also needs some padding (white pixels) */ + {0x04f9, 0x2060, "PT-E550W", 128, 180, FLAG_UNSUP_RASTER}, + /* Note about the PT-E550W: was reported by Tim Biermann but does not + work yet (only prints empty tape with FLAG_RASTER_PACKBITS|FLAG_HAS_PRECUT) */ {0x04f9, 0x2061, "PT-P700", 128, 180, FLAG_RASTER_PACKBITS|FLAG_P700_INIT|FLAG_HAS_PRECUT}, {0x04f9, 0x2062, "PT-P750W", 128, 180, FLAG_RASTER_PACKBITS|FLAG_P700_INIT}, {0x04f9, 0x2064, "PT-P700 (PLite Mode)", 128, 180, FLAG_PLITE}, From d7d97eede8353f0f56dd394c715aacfd81ab1e7d Mon Sep 17 00:00:00 2001 From: Dominic Radermacher Date: Sun, 3 Aug 2025 14:21:56 +0200 Subject: [PATCH 37/53] fix gettext.cmake --- cmake/gettext.cmake | 64 +++++++++---------- po/de.po | 140 ++++++++++++++++++++++++++++++------------ po/en.po | 140 ++++++++++++++++++++++++++++++------------ po/ptouch.pot | 146 +++++++++++++++++++++++++++++++------------- 4 files changed, 333 insertions(+), 157 deletions(-) diff --git a/cmake/gettext.cmake b/cmake/gettext.cmake index 21d6155..c48fe66 100644 --- a/cmake/gettext.cmake +++ b/cmake/gettext.cmake @@ -1,17 +1,15 @@ # Utilize gettext multilingual internationalization services if(Gettext_FOUND) - add_custom_target( - pot-update - ALL - DEPENDS ${CMAKE_SOURCE_DIR}/po/ptouch.pot - ) - add_dependencies(pot-update git-version) - # generate pot files using xgettext + find_program(GETTEXT_XGETTEXT_EXECUTABLE xgettext) if(GETTEXT_XGETTEXT_EXECUTABLE) + add_custom_target( + pot-update + ALL + DEPENDS ${CMAKE_SOURCE_DIR}/po/ptouch.pot + ) + file(GLOB_RECURSE C_FILES RELATIVE ${CMAKE_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/src/*.c) - file(STRINGS ${CMAKE_BINARY_DIR}/version.h VERSION_LINE REGEX "VERSION") - string(REGEX MATCH "\".*\"$" PVERSION ${VERSION_LINE}) add_custom_command( TARGET pot-update PRE_BUILD @@ -20,40 +18,38 @@ if(Gettext_FOUND) --keyword=N_ --force-po --package-name=${PROJECT_NAME} - --package-version=${PVERSION} --copyright-holder="Dominic Radermacher " --msgid-bugs-address="dominic@familie-radermacher.ch" --output ${CMAKE_SOURCE_DIR}/po/ptouch.pot ${C_FILES} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} ) - else() - message(DEBUG "Variable GETTEXT_XGETTEXT_EXECUTABLE not set") - endif() - # read available languages from LINGUAS file while ignoring comments - file(STRINGS po/LINGUAS LINGUAS REGEX "^[^#]") + # read available languages from LINGUAS file while ignoring comments + file(STRINGS po/LINGUAS LINGUAS REGEX "^[^#]") - # merge po files - if(GETTEXT_MSGMERGE_EXECUTABLE) - add_custom_target( - po-merge - ALL - DEPENDS ${CMAKE_SOURCE_DIR}/po/ptouch.pot - ) - add_dependencies(po-merge pot-update) - - foreach(LINGUA IN LISTS LINGUAS) - add_custom_command( - TARGET po-merge - PRE_BUILD - COMMAND ${GETTEXT_MSGMERGE_EXECUTABLE} - --update - --quiet - ${CMAKE_SOURCE_DIR}/po/${LINGUA}.po - ${CMAKE_SOURCE_DIR}/po/ptouch.pot + # merge po files + find_program(GETTEXT_MSGMERGE_EXECUTABLE msgmerge) + if(GETTEXT_MSGMERGE_EXECUTABLE) + add_custom_target( + po-merge + ALL + DEPENDS ${CMAKE_SOURCE_DIR}/po/ptouch.pot ) - endforeach() + add_dependencies(po-merge pot-update) + + foreach(LINGUA IN LISTS LINGUAS) + add_custom_command( + TARGET po-merge + PRE_BUILD + COMMAND ${GETTEXT_MSGMERGE_EXECUTABLE} + --update + --quiet + ${CMAKE_SOURCE_DIR}/po/${LINGUA}.po + ${CMAKE_SOURCE_DIR}/po/ptouch.pot + ) + endforeach() + endif() endif() # compile po files diff --git a/po/de.po b/po/de.po index d544bb1..9455dee 100644 --- a/po/de.po +++ b/po/de.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: ptouch-print 1.3.1\n" "Report-Msgid-Bugs-To: dominic@familie-radermacher.ch\n" -"POT-Creation-Date: 2024-05-23 22:20-0400\n" +"POT-Creation-Date: 2025-08-03 10:11+0200\n" "PO-Revision-Date: 2024-05-23 22:27-0400\n" "Last-Translator: dominic@familie-radermacher.ch\n" "Language-Team: German \n" @@ -19,117 +19,162 @@ msgstr "" "Plural-Forms: nplurals=2; plural=(n != 1);\n" "X-Generator: Poedit 2.4.2\n" -#: src/libptouch.c:95 src/libptouch.c:99 src/libptouch.c:103 +#: src/libptouch.c:105 src/libptouch.c:109 src/libptouch.c:113 #, c-format msgid "out of memory\n" msgstr "Nicht genug Speicher\n" -#: src/libptouch.c:107 +#: src/libptouch.c:117 #, c-format msgid "libusb_init() failed\n" msgstr "ptouch_init() fehlgeschlagen\n" -#: src/libptouch.c:116 +#: src/libptouch.c:126 #, c-format msgid "failed to get device descriptor" msgstr "" -#: src/libptouch.c:122 +#: src/libptouch.c:132 #, c-format msgid "%s found on USB bus %d, device %d\n" msgstr "Drucker %s am USB Bus %d, Gerät %d gefunden\n" -#: src/libptouch.c:137 +#: src/libptouch.c:147 #, c-format msgid "libusb_open error :%s\n" msgstr "" -#: src/libptouch.c:143 +#: src/libptouch.c:153 #, c-format msgid "error while detaching kernel driver: %s\n" msgstr "" -#: src/libptouch.c:147 +#: src/libptouch.c:157 #, c-format msgid "interface claim error: %s\n" msgstr "" -#: src/libptouch.c:158 +#: src/libptouch.c:168 #, c-format msgid "" "No P-Touch printer found on USB (remember to put switch to position E)\n" msgstr "Kein P-Ptouch Drucker am USB gefunden (Schalter muss auf E stehen)\n" -#: src/libptouch.c:178 +#: src/libptouch.c:188 +#, c-format +msgid "debug: called ptouch_send() with NULL ptdev\n" +msgstr "" + +#: src/libptouch.c:195 #, c-format msgid "write error: %s\n" msgstr "" -#: src/libptouch.c:182 +#: src/libptouch.c:199 #, fuzzy, c-format msgid "write error: could send only %i of %ld bytes\n" msgstr "Lesefehler: %i anstatt 32 bytes empfangen\n" -#: src/libptouch.c:302 +#: src/libptouch.c:248 +#, c-format +msgid "debug: called ptouch_info_cmd() with NULL ptdev\n" +msgstr "" + +#: src/libptouch.c:290 +#, fuzzy, c-format +msgid "debug: called ptouch_rasterstart() with NULL ptdev\n" +msgstr "ptouch_rasterstart() fehlgeschlagen\n" + +#: src/libptouch.c:321 +#, c-format +msgid "debug: called ptouch_finalize() with NULL ptdev\n" +msgstr "" + +#: src/libptouch.c:336 #, c-format msgid "debug: dumping raw status bytes\n" msgstr "" -#: src/libptouch.c:326 src/libptouch.c:362 +#: src/libptouch.c:355 +#, c-format +msgid "debug: called ptouch_getstatus() with NULL ptdev\n" +msgstr "" + +#: src/libptouch.c:365 src/libptouch.c:401 #, c-format msgid "read error: %s\n" msgstr "" -#: src/libptouch.c:331 +#: src/libptouch.c:370 #, c-format msgid "timeout while waiting for status response\n" msgstr "" -#: src/libptouch.c:345 +#: src/libptouch.c:384 #, c-format msgid "unknown tape width of %imm, please report this.\n" msgstr "Unbekannte Schriftband breite (%i mm), bitte melden\n" -#: src/libptouch.c:351 +#: src/libptouch.c:390 #, c-format msgid "got only 16 bytes... wondering what they are:\n" msgstr "nur 16 bytes empfangen... mal gucken was die sind:\n" -#: src/libptouch.c:355 +#: src/libptouch.c:394 #, c-format msgid "read error: got %i instead of 32 bytes\n" msgstr "Lesefehler: %i anstatt 32 bytes empfangen\n" -#: src/libptouch.c:358 +#: src/libptouch.c:397 #, c-format msgid "strange status:\n" msgstr "Seltsamer Status:\n" -#: src/libptouch.c:360 +#: src/libptouch.c:399 #, c-format msgid "trying to flush junk\n" msgstr "" -#: src/libptouch.c:365 +#: src/libptouch.c:404 #, c-format msgid "got another %i bytes. now try again\n" msgstr "weitere %i bytes empfangen. probiere es nochmal.\n" +#: src/libptouch.c:411 +#, c-format +msgid "debug: called ptouch_get_tape_width() with NULL ptdev\n" +msgstr "" + +#: src/libptouch.c:420 +#, c-format +msgid "debug: called ptouch_get_max_width() with NULL ptdev\n" +msgstr "" + +#: src/libptouch.c:432 +#, c-format +msgid "debug: called ptouch_sendraster() with NULL ptdev\n" +msgstr "" + #: src/ptouch-print.c:82 #, c-format msgid "nothing to print\n" msgstr "" -#: src/ptouch-print.c:89 +#: src/ptouch-print.c:90 #, c-format msgid "image is too large (%ipx x %ipx)\n" msgstr "Bild ist zu gross (%ipx x %ipx)\n" -#: src/ptouch-print.c:90 src/ptouch-print.c:556 +#: src/ptouch-print.c:91 #, c-format msgid "maximum printing width for this tape is %ipx\n" msgstr "Maximal druckbare Breite für dieses Schriftband sind %ipx\n" +#: src/ptouch-print.c:94 +#, fuzzy, c-format +msgid "image size (%ipx x %ipx)\n" +msgstr "Bild ist zu gross (%ipx x %ipx)\n" + #: src/ptouch-print.c:104 #, c-format msgid "ptouch_rasterstart() failed\n" @@ -140,92 +185,107 @@ msgstr "ptouch_rasterstart() fehlgeschlagen\n" msgid "send print information command\n" msgstr "" -#: src/ptouch-print.c:116 +#: src/ptouch-print.c:117 #, c-format -msgid "send PT-D460BT magic commands\n" +msgid "send PT-D460BT chain commands\n" msgstr "" #: src/ptouch-print.c:122 #, c-format +msgid "send PT-D460BT magic commands\n" +msgstr "" + +#: src/ptouch-print.c:128 +#, c-format msgid "send precut command\n" msgstr "" -#: src/ptouch-print.c:133 +#: src/ptouch-print.c:139 #, fuzzy, c-format msgid "ptouch_sendraster() failed\n" msgstr "ptouch_send() fehlgeschlagen\n" -#: src/ptouch-print.c:182 +#: src/ptouch-print.c:188 #, c-format msgid "writing image '%s' failed\n" msgstr "Schreiben der Bilddatei '%s' fehlgeschlagen\n" -#: src/ptouch-print.c:206 +#: src/ptouch-print.c:210 #, c-format msgid "debug: o baseline offset - %d\n" msgstr "" -#: src/ptouch-print.c:207 +#: src/ptouch-print.c:211 #, c-format msgid "debug: text baseline offset - %d\n" msgstr "" -#: src/ptouch-print.c:266 +#: src/ptouch-print.c:270 #, c-format msgid "render_text(): %i lines, font = '%s'\n" msgstr "" -#: src/ptouch-print.c:269 +#: src/ptouch-print.c:273 #, c-format msgid "warning: font config not available\n" msgstr "Warnung: fontconfig ist nicht verfügbar\n" -#: src/ptouch-print.c:273 +#: src/ptouch-print.c:277 #, c-format msgid "setting font size=%i\n" msgstr "setze Zeichensatzgrösse=%i\n" -#: src/ptouch-print.c:277 +#: src/ptouch-print.c:281 #, c-format msgid "could not estimate needed font size\n" msgstr "Konnte die notwendige Zeichensatzgrösse nicht bestimmen\n" -#: src/ptouch-print.c:284 +#: src/ptouch-print.c:288 #, c-format msgid "choosing font size=%i\n" msgstr "Wähle Zeichensatzgrösse %i\n" -#: src/ptouch-print.c:300 src/ptouch-print.c:328 +#: src/ptouch-print.c:304 src/ptouch-print.c:332 #, c-format msgid "error in gdImageStringFT: %s\n" msgstr "Fehler in Funktion gdImageStringFT(): %s\n" -#: src/ptouch-print.c:495 +#: src/ptouch-print.c:514 #, c-format msgid "ptouch-print version %s by Dominic Radermacher\n" msgstr "ptouch-print Version %s von Dominic Radermacher\n" -#: src/ptouch-print.c:526 +#: src/ptouch-print.c:553 #, c-format msgid "ptouch_init() failed\n" msgstr "ptouch_init() fehlgeschlagen\n" -#: src/ptouch-print.c:529 +#: src/ptouch-print.c:556 #, c-format msgid "ptouch_getstatus() failed\n" msgstr "ptouch_getstatus() fehlgeschlagen\n" -#: src/ptouch-print.c:568 +#: src/ptouch-print.c:595 +#, fuzzy, c-format +msgid "maximum printing width for this printer is %ldpx\n" +msgstr "Maximal druckbare Breite für dieses Schriftband sind %ipx\n" + +#: src/ptouch-print.c:596 +#, fuzzy, c-format +msgid "maximum printing width for this tape is %ldpx\n" +msgstr "Maximal druckbare Breite für dieses Schriftband sind %ipx\n" + +#: src/ptouch-print.c:608 #, c-format msgid "failed to load image file\n" msgstr "" -#: src/ptouch-print.c:584 +#: src/ptouch-print.c:624 #, c-format msgid "could not render text\n" msgstr "Konnte Text nicht rendern\n" -#: src/ptouch-print.c:616 +#: src/ptouch-print.c:659 #, c-format msgid "ptouch_finalize(%d) failed\n" msgstr "ptouch_finalize(%d) fehlgeschlagen\n" diff --git a/po/en.po b/po/en.po index c495d46..ac36335 100644 --- a/po/en.po +++ b/po/en.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: ptouch-print 1.3.1\n" "Report-Msgid-Bugs-To: dominic@familie-radermacher.ch\n" -"POT-Creation-Date: 2024-05-23 22:20-0400\n" +"POT-Creation-Date: 2025-08-03 10:11+0200\n" "PO-Revision-Date: 2024-05-23 22:26-0400\n" "Last-Translator: dominic@familie-radermacher.ch\n" "Language-Team: English \n" @@ -18,118 +18,163 @@ msgstr "" "Plural-Forms: nplurals=2; plural=(n != 1);\n" "X-Generator: Poedit 2.4.2\n" -#: src/libptouch.c:95 src/libptouch.c:99 src/libptouch.c:103 +#: src/libptouch.c:105 src/libptouch.c:109 src/libptouch.c:113 #, c-format msgid "out of memory\n" msgstr "out of memory\n" -#: src/libptouch.c:107 +#: src/libptouch.c:117 #, c-format msgid "libusb_init() failed\n" msgstr "libusb_init() failed\n" -#: src/libptouch.c:116 +#: src/libptouch.c:126 #, c-format msgid "failed to get device descriptor" msgstr "failed to get device descriptor" -#: src/libptouch.c:122 +#: src/libptouch.c:132 #, c-format msgid "%s found on USB bus %d, device %d\n" msgstr "%s found on USB bus %d, device %d\n" -#: src/libptouch.c:137 +#: src/libptouch.c:147 #, c-format msgid "libusb_open error :%s\n" msgstr "libusb_open error :%s\n" -#: src/libptouch.c:143 +#: src/libptouch.c:153 #, c-format msgid "error while detaching kernel driver: %s\n" msgstr "error while detaching kernel driver: %s\n" -#: src/libptouch.c:147 +#: src/libptouch.c:157 #, c-format msgid "interface claim error: %s\n" msgstr "interface claim error: %s\n" -#: src/libptouch.c:158 +#: src/libptouch.c:168 #, c-format msgid "" "No P-Touch printer found on USB (remember to put switch to position E)\n" msgstr "" "No P-Touch printer found on USB (remember to put switch to position E)\n" -#: src/libptouch.c:178 +#: src/libptouch.c:188 +#, c-format +msgid "debug: called ptouch_send() with NULL ptdev\n" +msgstr "" + +#: src/libptouch.c:195 #, c-format msgid "write error: %s\n" msgstr "write error: %s\n" -#: src/libptouch.c:182 +#: src/libptouch.c:199 #, fuzzy, c-format msgid "write error: could send only %i of %ld bytes\n" msgstr "write error: could send only %i of %i bytes\n" -#: src/libptouch.c:302 +#: src/libptouch.c:248 +#, c-format +msgid "debug: called ptouch_info_cmd() with NULL ptdev\n" +msgstr "" + +#: src/libptouch.c:290 +#, fuzzy, c-format +msgid "debug: called ptouch_rasterstart() with NULL ptdev\n" +msgstr "ptouch_rasterstart() failed\n" + +#: src/libptouch.c:321 +#, c-format +msgid "debug: called ptouch_finalize() with NULL ptdev\n" +msgstr "" + +#: src/libptouch.c:336 #, c-format msgid "debug: dumping raw status bytes\n" msgstr "debug: dumping raw status bytes\n" -#: src/libptouch.c:326 src/libptouch.c:362 +#: src/libptouch.c:355 +#, c-format +msgid "debug: called ptouch_getstatus() with NULL ptdev\n" +msgstr "" + +#: src/libptouch.c:365 src/libptouch.c:401 #, c-format msgid "read error: %s\n" msgstr "read error: %s\n" -#: src/libptouch.c:331 +#: src/libptouch.c:370 #, c-format msgid "timeout while waiting for status response\n" msgstr "timeout while waiting for status response\n" -#: src/libptouch.c:345 +#: src/libptouch.c:384 #, c-format msgid "unknown tape width of %imm, please report this.\n" msgstr "unknown tape width of %imm, please report this.\n" -#: src/libptouch.c:351 +#: src/libptouch.c:390 #, c-format msgid "got only 16 bytes... wondering what they are:\n" msgstr "got only 16 bytes... wondering what they are:\n" -#: src/libptouch.c:355 +#: src/libptouch.c:394 #, c-format msgid "read error: got %i instead of 32 bytes\n" msgstr "read error: got %i instead of 32 bytes\n" -#: src/libptouch.c:358 +#: src/libptouch.c:397 #, c-format msgid "strange status:\n" msgstr "strange status:\n" -#: src/libptouch.c:360 +#: src/libptouch.c:399 #, c-format msgid "trying to flush junk\n" msgstr "trying to flush junk\n" -#: src/libptouch.c:365 +#: src/libptouch.c:404 #, c-format msgid "got another %i bytes. now try again\n" msgstr "got another %i bytes. now try again\n" +#: src/libptouch.c:411 +#, c-format +msgid "debug: called ptouch_get_tape_width() with NULL ptdev\n" +msgstr "" + +#: src/libptouch.c:420 +#, c-format +msgid "debug: called ptouch_get_max_width() with NULL ptdev\n" +msgstr "" + +#: src/libptouch.c:432 +#, c-format +msgid "debug: called ptouch_sendraster() with NULL ptdev\n" +msgstr "" + #: src/ptouch-print.c:82 #, c-format msgid "nothing to print\n" msgstr "" -#: src/ptouch-print.c:89 +#: src/ptouch-print.c:90 #, c-format msgid "image is too large (%ipx x %ipx)\n" msgstr "image is too large (%ipx x %ipx)\n" -#: src/ptouch-print.c:90 src/ptouch-print.c:556 +#: src/ptouch-print.c:91 #, c-format msgid "maximum printing width for this tape is %ipx\n" msgstr "maximum printing width for this tape is %ipx\n" +#: src/ptouch-print.c:94 +#, fuzzy, c-format +msgid "image size (%ipx x %ipx)\n" +msgstr "image is too large (%ipx x %ipx)\n" + #: src/ptouch-print.c:104 #, c-format msgid "ptouch_rasterstart() failed\n" @@ -140,92 +185,107 @@ msgstr "ptouch_rasterstart() failed\n" msgid "send print information command\n" msgstr "" -#: src/ptouch-print.c:116 +#: src/ptouch-print.c:117 #, c-format -msgid "send PT-D460BT magic commands\n" +msgid "send PT-D460BT chain commands\n" msgstr "" #: src/ptouch-print.c:122 #, c-format +msgid "send PT-D460BT magic commands\n" +msgstr "" + +#: src/ptouch-print.c:128 +#, c-format msgid "send precut command\n" msgstr "" -#: src/ptouch-print.c:133 +#: src/ptouch-print.c:139 #, c-format msgid "ptouch_sendraster() failed\n" msgstr "ptouch_sendraster() failed\n" -#: src/ptouch-print.c:182 +#: src/ptouch-print.c:188 #, c-format msgid "writing image '%s' failed\n" msgstr "writing image '%s' failed\n" -#: src/ptouch-print.c:206 +#: src/ptouch-print.c:210 #, c-format msgid "debug: o baseline offset - %d\n" msgstr "" -#: src/ptouch-print.c:207 +#: src/ptouch-print.c:211 #, c-format msgid "debug: text baseline offset - %d\n" msgstr "" -#: src/ptouch-print.c:266 +#: src/ptouch-print.c:270 #, c-format msgid "render_text(): %i lines, font = '%s'\n" msgstr "" -#: src/ptouch-print.c:269 +#: src/ptouch-print.c:273 #, c-format msgid "warning: font config not available\n" msgstr "warning: font config not available\n" -#: src/ptouch-print.c:273 +#: src/ptouch-print.c:277 #, c-format msgid "setting font size=%i\n" msgstr "setting font size=%i\n" -#: src/ptouch-print.c:277 +#: src/ptouch-print.c:281 #, c-format msgid "could not estimate needed font size\n" msgstr "could not estimate needed font size\n" -#: src/ptouch-print.c:284 +#: src/ptouch-print.c:288 #, c-format msgid "choosing font size=%i\n" msgstr "choosing font size=%i\n" -#: src/ptouch-print.c:300 src/ptouch-print.c:328 +#: src/ptouch-print.c:304 src/ptouch-print.c:332 #, c-format msgid "error in gdImageStringFT: %s\n" msgstr "error in gdImageStringFT: %s\n" -#: src/ptouch-print.c:495 +#: src/ptouch-print.c:514 #, c-format msgid "ptouch-print version %s by Dominic Radermacher\n" msgstr "ptouch-print version %s by Dominic Radermacher\n" -#: src/ptouch-print.c:526 +#: src/ptouch-print.c:553 #, c-format msgid "ptouch_init() failed\n" msgstr "ptouch_init() failed\n" -#: src/ptouch-print.c:529 +#: src/ptouch-print.c:556 #, c-format msgid "ptouch_getstatus() failed\n" msgstr "ptouch_getstatus() failed\n" -#: src/ptouch-print.c:568 +#: src/ptouch-print.c:595 +#, fuzzy, c-format +msgid "maximum printing width for this printer is %ldpx\n" +msgstr "maximum printing width for this tape is %ipx\n" + +#: src/ptouch-print.c:596 +#, fuzzy, c-format +msgid "maximum printing width for this tape is %ldpx\n" +msgstr "maximum printing width for this tape is %ipx\n" + +#: src/ptouch-print.c:608 #, c-format msgid "failed to load image file\n" msgstr "" -#: src/ptouch-print.c:584 +#: src/ptouch-print.c:624 #, c-format msgid "could not render text\n" msgstr "could not render text\n" -#: src/ptouch-print.c:616 +#: src/ptouch-print.c:659 #, c-format msgid "ptouch_finalize(%d) failed\n" msgstr "ptouch_finalize(%d) failed\n" diff --git a/po/ptouch.pot b/po/ptouch.pot index cb22f35..3a4f9b5 100644 --- a/po/ptouch.pot +++ b/po/ptouch.pot @@ -1,14 +1,14 @@ # SOME DESCRIPTIVE TITLE. -# Copyright (C) YEAR Free Software Foundation, Inc. -# This file is distributed under the same license as the ptouch package. +# Copyright (C) YEAR Dominic\ Radermacher\ +# This file is distributed under the same license as the ptouch-print package. # FIRST AUTHOR , YEAR. # #, fuzzy msgid "" msgstr "" -"Project-Id-Version: ptouch 1.3.3\n" +"Project-Id-Version: ptouch-print\n" "Report-Msgid-Bugs-To: dominic@familie-radermacher.ch\n" -"POT-Creation-Date: 2024-05-23 22:20-0400\n" +"POT-Creation-Date: 2025-08-03 10:11+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -17,117 +17,162 @@ msgstr "" "Content-Type: text/plain; charset=CHARSET\n" "Content-Transfer-Encoding: 8bit\n" -#: src/libptouch.c:95 src/libptouch.c:99 src/libptouch.c:103 +#: src/libptouch.c:105 src/libptouch.c:109 src/libptouch.c:113 #, c-format msgid "out of memory\n" msgstr "" -#: src/libptouch.c:107 +#: src/libptouch.c:117 #, c-format msgid "libusb_init() failed\n" msgstr "" -#: src/libptouch.c:116 +#: src/libptouch.c:126 #, c-format msgid "failed to get device descriptor" msgstr "" -#: src/libptouch.c:122 +#: src/libptouch.c:132 #, c-format msgid "%s found on USB bus %d, device %d\n" msgstr "" -#: src/libptouch.c:137 +#: src/libptouch.c:147 #, c-format msgid "libusb_open error :%s\n" msgstr "" -#: src/libptouch.c:143 +#: src/libptouch.c:153 #, c-format msgid "error while detaching kernel driver: %s\n" msgstr "" -#: src/libptouch.c:147 +#: src/libptouch.c:157 #, c-format msgid "interface claim error: %s\n" msgstr "" -#: src/libptouch.c:158 +#: src/libptouch.c:168 #, c-format msgid "" "No P-Touch printer found on USB (remember to put switch to position E)\n" msgstr "" -#: src/libptouch.c:178 +#: src/libptouch.c:188 +#, c-format +msgid "debug: called ptouch_send() with NULL ptdev\n" +msgstr "" + +#: src/libptouch.c:195 #, c-format msgid "write error: %s\n" msgstr "" -#: src/libptouch.c:182 +#: src/libptouch.c:199 #, c-format msgid "write error: could send only %i of %ld bytes\n" msgstr "" -#: src/libptouch.c:302 +#: src/libptouch.c:248 +#, c-format +msgid "debug: called ptouch_info_cmd() with NULL ptdev\n" +msgstr "" + +#: src/libptouch.c:290 +#, c-format +msgid "debug: called ptouch_rasterstart() with NULL ptdev\n" +msgstr "" + +#: src/libptouch.c:321 +#, c-format +msgid "debug: called ptouch_finalize() with NULL ptdev\n" +msgstr "" + +#: src/libptouch.c:336 #, c-format msgid "debug: dumping raw status bytes\n" msgstr "" -#: src/libptouch.c:326 src/libptouch.c:362 +#: src/libptouch.c:355 +#, c-format +msgid "debug: called ptouch_getstatus() with NULL ptdev\n" +msgstr "" + +#: src/libptouch.c:365 src/libptouch.c:401 #, c-format msgid "read error: %s\n" msgstr "" -#: src/libptouch.c:331 +#: src/libptouch.c:370 #, c-format msgid "timeout while waiting for status response\n" msgstr "" -#: src/libptouch.c:345 +#: src/libptouch.c:384 #, c-format msgid "unknown tape width of %imm, please report this.\n" msgstr "" -#: src/libptouch.c:351 +#: src/libptouch.c:390 #, c-format msgid "got only 16 bytes... wondering what they are:\n" msgstr "" -#: src/libptouch.c:355 +#: src/libptouch.c:394 #, c-format msgid "read error: got %i instead of 32 bytes\n" msgstr "" -#: src/libptouch.c:358 +#: src/libptouch.c:397 #, c-format msgid "strange status:\n" msgstr "" -#: src/libptouch.c:360 +#: src/libptouch.c:399 #, c-format msgid "trying to flush junk\n" msgstr "" -#: src/libptouch.c:365 +#: src/libptouch.c:404 #, c-format msgid "got another %i bytes. now try again\n" msgstr "" +#: src/libptouch.c:411 +#, c-format +msgid "debug: called ptouch_get_tape_width() with NULL ptdev\n" +msgstr "" + +#: src/libptouch.c:420 +#, c-format +msgid "debug: called ptouch_get_max_width() with NULL ptdev\n" +msgstr "" + +#: src/libptouch.c:432 +#, c-format +msgid "debug: called ptouch_sendraster() with NULL ptdev\n" +msgstr "" + #: src/ptouch-print.c:82 #, c-format msgid "nothing to print\n" msgstr "" -#: src/ptouch-print.c:89 +#: src/ptouch-print.c:90 #, c-format msgid "image is too large (%ipx x %ipx)\n" msgstr "" -#: src/ptouch-print.c:90 src/ptouch-print.c:556 +#: src/ptouch-print.c:91 #, c-format msgid "maximum printing width for this tape is %ipx\n" msgstr "" +#: src/ptouch-print.c:94 +#, c-format +msgid "image size (%ipx x %ipx)\n" +msgstr "" + #: src/ptouch-print.c:104 #, c-format msgid "ptouch_rasterstart() failed\n" @@ -138,92 +183,107 @@ msgstr "" msgid "send print information command\n" msgstr "" -#: src/ptouch-print.c:116 +#: src/ptouch-print.c:117 #, c-format -msgid "send PT-D460BT magic commands\n" +msgid "send PT-D460BT chain commands\n" msgstr "" #: src/ptouch-print.c:122 #, c-format +msgid "send PT-D460BT magic commands\n" +msgstr "" + +#: src/ptouch-print.c:128 +#, c-format msgid "send precut command\n" msgstr "" -#: src/ptouch-print.c:133 +#: src/ptouch-print.c:139 #, c-format msgid "ptouch_sendraster() failed\n" msgstr "" -#: src/ptouch-print.c:182 +#: src/ptouch-print.c:188 #, c-format msgid "writing image '%s' failed\n" msgstr "" -#: src/ptouch-print.c:206 +#: src/ptouch-print.c:210 #, c-format msgid "debug: o baseline offset - %d\n" msgstr "" -#: src/ptouch-print.c:207 +#: src/ptouch-print.c:211 #, c-format msgid "debug: text baseline offset - %d\n" msgstr "" -#: src/ptouch-print.c:266 +#: src/ptouch-print.c:270 #, c-format msgid "render_text(): %i lines, font = '%s'\n" msgstr "" -#: src/ptouch-print.c:269 +#: src/ptouch-print.c:273 #, c-format msgid "warning: font config not available\n" msgstr "" -#: src/ptouch-print.c:273 +#: src/ptouch-print.c:277 #, c-format msgid "setting font size=%i\n" msgstr "" -#: src/ptouch-print.c:277 +#: src/ptouch-print.c:281 #, c-format msgid "could not estimate needed font size\n" msgstr "" -#: src/ptouch-print.c:284 +#: src/ptouch-print.c:288 #, c-format msgid "choosing font size=%i\n" msgstr "" -#: src/ptouch-print.c:300 src/ptouch-print.c:328 +#: src/ptouch-print.c:304 src/ptouch-print.c:332 #, c-format msgid "error in gdImageStringFT: %s\n" msgstr "" -#: src/ptouch-print.c:495 +#: src/ptouch-print.c:514 #, c-format msgid "ptouch-print version %s by Dominic Radermacher\n" msgstr "" -#: src/ptouch-print.c:526 +#: src/ptouch-print.c:553 #, c-format msgid "ptouch_init() failed\n" msgstr "" -#: src/ptouch-print.c:529 +#: src/ptouch-print.c:556 #, c-format msgid "ptouch_getstatus() failed\n" msgstr "" -#: src/ptouch-print.c:568 +#: src/ptouch-print.c:595 +#, c-format +msgid "maximum printing width for this printer is %ldpx\n" +msgstr "" + +#: src/ptouch-print.c:596 +#, c-format +msgid "maximum printing width for this tape is %ldpx\n" +msgstr "" + +#: src/ptouch-print.c:608 #, c-format msgid "failed to load image file\n" msgstr "" -#: src/ptouch-print.c:584 +#: src/ptouch-print.c:624 #, c-format msgid "could not render text\n" msgstr "" -#: src/ptouch-print.c:616 +#: src/ptouch-print.c:659 #, c-format msgid "ptouch_finalize(%d) failed\n" msgstr "" From ab80c721f6483d830ac9dd20ae5d7e073b324474 Mon Sep 17 00:00:00 2001 From: Dominic Radermacher Date: Sun, 10 Aug 2025 07:23:11 +0200 Subject: [PATCH 38/53] fix compile warning --- include/gettext.h | 288 --------------------------------------------- po/de.po | 56 ++++----- po/en.po | 56 ++++----- po/ptouch.pot | 56 ++++----- src/libptouch.c | 2 +- src/ptouch-print.c | 1 - 6 files changed, 85 insertions(+), 374 deletions(-) delete mode 100644 include/gettext.h diff --git a/include/gettext.h b/include/gettext.h deleted file mode 100644 index f37d586..0000000 --- a/include/gettext.h +++ /dev/null @@ -1,288 +0,0 @@ -/* Convenience header for conditional use of GNU . - Copyright (C) 1995-1998, 2000-2002, 2004-2006, 2009-2011, 2015 Free - Software Foundation, Inc. - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . */ - -#ifndef _LIBGETTEXT_H -#define _LIBGETTEXT_H 1 - -/* NLS can be disabled through the configure --disable-nls option. */ -#if ENABLE_NLS - -/* Get declarations of GNU message catalog functions. */ -# include - -/* You can set the DEFAULT_TEXT_DOMAIN macro to specify the domain used by - the gettext() and ngettext() macros. This is an alternative to calling - textdomain(), and is useful for libraries. */ -# ifdef DEFAULT_TEXT_DOMAIN -# undef gettext -# define gettext(Msgid) \ - dgettext (DEFAULT_TEXT_DOMAIN, Msgid) -# undef ngettext -# define ngettext(Msgid1, Msgid2, N) \ - dngettext (DEFAULT_TEXT_DOMAIN, Msgid1, Msgid2, N) -# endif - -#else - -/* Solaris /usr/include/locale.h includes /usr/include/libintl.h, which - chokes if dcgettext is defined as a macro. So include it now, to make - later inclusions of a NOP. We don't include - as well because people using "gettext.h" will not include , - and also including would fail on SunOS 4, whereas - is OK. */ -#if defined(__sun) -# include -#endif - -/* Many header files from the libstdc++ coming with g++ 3.3 or newer include - , which chokes if dcgettext is defined as a macro. So include - it now, to make later inclusions of a NOP. */ -#if defined(__cplusplus) && defined(__GNUG__) && (__GNUC__ >= 3) -# include -# if (__GLIBC__ >= 2 && !defined __UCLIBC__) || _GLIBCXX_HAVE_LIBINTL_H -# include -# endif -#endif - -/* Disabled NLS. - The casts to 'const char *' serve the purpose of producing warnings - for invalid uses of the value returned from these functions. - On pre-ANSI systems without 'const', the config.h file is supposed to - contain "#define const". */ -# undef gettext -# define gettext(Msgid) ((const char *) (Msgid)) -# undef dgettext -# define dgettext(Domainname, Msgid) ((void) (Domainname), gettext (Msgid)) -# undef dcgettext -# define dcgettext(Domainname, Msgid, Category) \ - ((void) (Category), dgettext (Domainname, Msgid)) -# undef ngettext -# define ngettext(Msgid1, Msgid2, N) \ - ((N) == 1 \ - ? ((void) (Msgid2), (const char *) (Msgid1)) \ - : ((void) (Msgid1), (const char *) (Msgid2))) -# undef dngettext -# define dngettext(Domainname, Msgid1, Msgid2, N) \ - ((void) (Domainname), ngettext (Msgid1, Msgid2, N)) -# undef dcngettext -# define dcngettext(Domainname, Msgid1, Msgid2, N, Category) \ - ((void) (Category), dngettext (Domainname, Msgid1, Msgid2, N)) -# undef textdomain -# define textdomain(Domainname) ((const char *) (Domainname)) -# undef bindtextdomain -# define bindtextdomain(Domainname, Dirname) \ - ((void) (Domainname), (const char *) (Dirname)) -# undef bind_textdomain_codeset -# define bind_textdomain_codeset(Domainname, Codeset) \ - ((void) (Domainname), (const char *) (Codeset)) - -#endif - -/* Prefer gnulib's setlocale override over libintl's setlocale override. */ -#ifdef GNULIB_defined_setlocale -# undef setlocale -# define setlocale rpl_setlocale -#endif - -/* A pseudo function call that serves as a marker for the automated - extraction of messages, but does not call gettext(). The run-time - translation is done at a different place in the code. - The argument, String, should be a literal string. Concatenated strings - and other string expressions won't work. - The macro's expansion is not parenthesized, so that it is suitable as - initializer for static 'char[]' or 'const char[]' variables. */ -#define gettext_noop(String) String - -/* The separator between msgctxt and msgid in a .mo file. */ -#define GETTEXT_CONTEXT_GLUE "\004" - -/* Pseudo function calls, taking a MSGCTXT and a MSGID instead of just a - MSGID. MSGCTXT and MSGID must be string literals. MSGCTXT should be - short and rarely need to change. - The letter 'p' stands for 'particular' or 'special'. */ -#ifdef DEFAULT_TEXT_DOMAIN -# define pgettext(Msgctxt, Msgid) \ - pgettext_aux (DEFAULT_TEXT_DOMAIN, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES) -#else -# define pgettext(Msgctxt, Msgid) \ - pgettext_aux (NULL, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES) -#endif -#define dpgettext(Domainname, Msgctxt, Msgid) \ - pgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES) -#define dcpgettext(Domainname, Msgctxt, Msgid, Category) \ - pgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, Category) -#ifdef DEFAULT_TEXT_DOMAIN -# define npgettext(Msgctxt, Msgid, MsgidPlural, N) \ - npgettext_aux (DEFAULT_TEXT_DOMAIN, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES) -#else -# define npgettext(Msgctxt, Msgid, MsgidPlural, N) \ - npgettext_aux (NULL, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES) -#endif -#define dnpgettext(Domainname, Msgctxt, Msgid, MsgidPlural, N) \ - npgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES) -#define dcnpgettext(Domainname, Msgctxt, Msgid, MsgidPlural, N, Category) \ - npgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, Category) - -#ifdef __GNUC__ -__inline -#else -#ifdef __cplusplus -inline -#endif -#endif -static const char * -pgettext_aux (const char *domain, - const char *msg_ctxt_id, const char *msgid, - int category) -{ - const char *translation = dcgettext (domain, msg_ctxt_id, category); - if (translation == msg_ctxt_id) - return msgid; - else - return translation; -} - -#ifdef __GNUC__ -__inline -#else -#ifdef __cplusplus -inline -#endif -#endif -static const char * -npgettext_aux (const char *domain, - const char *msg_ctxt_id, const char *msgid, - const char *msgid_plural, unsigned long int n, - int category) -{ - const char *translation = - dcngettext (domain, msg_ctxt_id, msgid_plural, n, category); - if (translation == msg_ctxt_id || translation == msgid_plural) - return (n == 1 ? msgid : msgid_plural); - else - return translation; -} - -/* The same thing extended for non-constant arguments. Here MSGCTXT and MSGID - can be arbitrary expressions. But for string literals these macros are - less efficient than those above. */ - -#include - -#if (((__GNUC__ >= 3 || __GNUG__ >= 2) && !defined __STRICT_ANSI__) \ - /* || __STDC_VERSION__ >= 199901L */ ) -# define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS 1 -#else -# define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS 0 -#endif - -#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS -#include -#endif - -#define pgettext_expr(Msgctxt, Msgid) \ - dcpgettext_expr (NULL, Msgctxt, Msgid, LC_MESSAGES) -#define dpgettext_expr(Domainname, Msgctxt, Msgid) \ - dcpgettext_expr (Domainname, Msgctxt, Msgid, LC_MESSAGES) - -#ifdef __GNUC__ -__inline -#else -#ifdef __cplusplus -inline -#endif -#endif -static const char * -dcpgettext_expr (const char *domain, - const char *msgctxt, const char *msgid, - int category) -{ - size_t msgctxt_len = strlen (msgctxt) + 1; - size_t msgid_len = strlen (msgid) + 1; - const char *translation; -#if _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS - char msg_ctxt_id[msgctxt_len + msgid_len]; -#else - char buf[1024]; - char *msg_ctxt_id = - (msgctxt_len + msgid_len <= sizeof (buf) - ? buf - : (char *) malloc (msgctxt_len + msgid_len)); - if (msg_ctxt_id != NULL) -#endif - { - memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1); - msg_ctxt_id[msgctxt_len - 1] = '\004'; - memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len); - translation = dcgettext (domain, msg_ctxt_id, category); -#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS - if (msg_ctxt_id != buf) - free (msg_ctxt_id); -#endif - if (translation != msg_ctxt_id) - return translation; - } - return msgid; -} - -#define npgettext_expr(Msgctxt, Msgid, MsgidPlural, N) \ - dcnpgettext_expr (NULL, Msgctxt, Msgid, MsgidPlural, N, LC_MESSAGES) -#define dnpgettext_expr(Domainname, Msgctxt, Msgid, MsgidPlural, N) \ - dcnpgettext_expr (Domainname, Msgctxt, Msgid, MsgidPlural, N, LC_MESSAGES) - -#ifdef __GNUC__ -__inline -#else -#ifdef __cplusplus -inline -#endif -#endif -static const char * -dcnpgettext_expr (const char *domain, - const char *msgctxt, const char *msgid, - const char *msgid_plural, unsigned long int n, - int category) -{ - size_t msgctxt_len = strlen (msgctxt) + 1; - size_t msgid_len = strlen (msgid) + 1; - const char *translation; -#if _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS - char msg_ctxt_id[msgctxt_len + msgid_len]; -#else - char buf[1024]; - char *msg_ctxt_id = - (msgctxt_len + msgid_len <= sizeof (buf) - ? buf - : (char *) malloc (msgctxt_len + msgid_len)); - if (msg_ctxt_id != NULL) -#endif - { - memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1); - msg_ctxt_id[msgctxt_len - 1] = '\004'; - memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len); - translation = dcngettext (domain, msg_ctxt_id, msgid_plural, n, category); -#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS - if (msg_ctxt_id != buf) - free (msg_ctxt_id); -#endif - if (!(translation == msg_ctxt_id || translation == msgid_plural)) - return translation; - } - return (n == 1 ? msgid : msgid_plural); -} - -#endif /* _LIBGETTEXT_H */ diff --git a/po/de.po b/po/de.po index 9455dee..f095f79 100644 --- a/po/de.po +++ b/po/de.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: ptouch-print 1.3.1\n" "Report-Msgid-Bugs-To: dominic@familie-radermacher.ch\n" -"POT-Creation-Date: 2025-08-03 10:11+0200\n" +"POT-Creation-Date: 2025-08-10 07:19+0200\n" "PO-Revision-Date: 2024-05-23 22:27-0400\n" "Last-Translator: dominic@familie-radermacher.ch\n" "Language-Team: German \n" @@ -155,137 +155,137 @@ msgstr "" msgid "debug: called ptouch_sendraster() with NULL ptdev\n" msgstr "" -#: src/ptouch-print.c:82 +#: src/ptouch-print.c:81 #, c-format msgid "nothing to print\n" msgstr "" -#: src/ptouch-print.c:90 +#: src/ptouch-print.c:89 #, c-format msgid "image is too large (%ipx x %ipx)\n" msgstr "Bild ist zu gross (%ipx x %ipx)\n" -#: src/ptouch-print.c:91 +#: src/ptouch-print.c:90 #, c-format msgid "maximum printing width for this tape is %ipx\n" msgstr "Maximal druckbare Breite für dieses Schriftband sind %ipx\n" -#: src/ptouch-print.c:94 +#: src/ptouch-print.c:93 #, fuzzy, c-format msgid "image size (%ipx x %ipx)\n" msgstr "Bild ist zu gross (%ipx x %ipx)\n" -#: src/ptouch-print.c:104 +#: src/ptouch-print.c:103 #, c-format msgid "ptouch_rasterstart() failed\n" msgstr "ptouch_rasterstart() fehlgeschlagen\n" -#: src/ptouch-print.c:110 +#: src/ptouch-print.c:109 #, c-format msgid "send print information command\n" msgstr "" -#: src/ptouch-print.c:117 +#: src/ptouch-print.c:116 #, c-format msgid "send PT-D460BT chain commands\n" msgstr "" -#: src/ptouch-print.c:122 +#: src/ptouch-print.c:121 #, c-format msgid "send PT-D460BT magic commands\n" msgstr "" -#: src/ptouch-print.c:128 +#: src/ptouch-print.c:127 #, c-format msgid "send precut command\n" msgstr "" -#: src/ptouch-print.c:139 +#: src/ptouch-print.c:138 #, fuzzy, c-format msgid "ptouch_sendraster() failed\n" msgstr "ptouch_send() fehlgeschlagen\n" -#: src/ptouch-print.c:188 +#: src/ptouch-print.c:187 #, c-format msgid "writing image '%s' failed\n" msgstr "Schreiben der Bilddatei '%s' fehlgeschlagen\n" -#: src/ptouch-print.c:210 +#: src/ptouch-print.c:209 #, c-format msgid "debug: o baseline offset - %d\n" msgstr "" -#: src/ptouch-print.c:211 +#: src/ptouch-print.c:210 #, c-format msgid "debug: text baseline offset - %d\n" msgstr "" -#: src/ptouch-print.c:270 +#: src/ptouch-print.c:269 #, c-format msgid "render_text(): %i lines, font = '%s'\n" msgstr "" -#: src/ptouch-print.c:273 +#: src/ptouch-print.c:272 #, c-format msgid "warning: font config not available\n" msgstr "Warnung: fontconfig ist nicht verfügbar\n" -#: src/ptouch-print.c:277 +#: src/ptouch-print.c:276 #, c-format msgid "setting font size=%i\n" msgstr "setze Zeichensatzgrösse=%i\n" -#: src/ptouch-print.c:281 +#: src/ptouch-print.c:280 #, c-format msgid "could not estimate needed font size\n" msgstr "Konnte die notwendige Zeichensatzgrösse nicht bestimmen\n" -#: src/ptouch-print.c:288 +#: src/ptouch-print.c:287 #, c-format msgid "choosing font size=%i\n" msgstr "Wähle Zeichensatzgrösse %i\n" -#: src/ptouch-print.c:304 src/ptouch-print.c:332 +#: src/ptouch-print.c:303 src/ptouch-print.c:331 #, c-format msgid "error in gdImageStringFT: %s\n" msgstr "Fehler in Funktion gdImageStringFT(): %s\n" -#: src/ptouch-print.c:514 +#: src/ptouch-print.c:513 #, c-format msgid "ptouch-print version %s by Dominic Radermacher\n" msgstr "ptouch-print Version %s von Dominic Radermacher\n" -#: src/ptouch-print.c:553 +#: src/ptouch-print.c:552 #, c-format msgid "ptouch_init() failed\n" msgstr "ptouch_init() fehlgeschlagen\n" -#: src/ptouch-print.c:556 +#: src/ptouch-print.c:555 #, c-format msgid "ptouch_getstatus() failed\n" msgstr "ptouch_getstatus() fehlgeschlagen\n" -#: src/ptouch-print.c:595 +#: src/ptouch-print.c:594 #, fuzzy, c-format msgid "maximum printing width for this printer is %ldpx\n" msgstr "Maximal druckbare Breite für dieses Schriftband sind %ipx\n" -#: src/ptouch-print.c:596 +#: src/ptouch-print.c:595 #, fuzzy, c-format msgid "maximum printing width for this tape is %ldpx\n" msgstr "Maximal druckbare Breite für dieses Schriftband sind %ipx\n" -#: src/ptouch-print.c:608 +#: src/ptouch-print.c:607 #, c-format msgid "failed to load image file\n" msgstr "" -#: src/ptouch-print.c:624 +#: src/ptouch-print.c:623 #, c-format msgid "could not render text\n" msgstr "Konnte Text nicht rendern\n" -#: src/ptouch-print.c:659 +#: src/ptouch-print.c:658 #, c-format msgid "ptouch_finalize(%d) failed\n" msgstr "ptouch_finalize(%d) fehlgeschlagen\n" diff --git a/po/en.po b/po/en.po index ac36335..99ad1fe 100644 --- a/po/en.po +++ b/po/en.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: ptouch-print 1.3.1\n" "Report-Msgid-Bugs-To: dominic@familie-radermacher.ch\n" -"POT-Creation-Date: 2025-08-03 10:11+0200\n" +"POT-Creation-Date: 2025-08-10 07:19+0200\n" "PO-Revision-Date: 2024-05-23 22:26-0400\n" "Last-Translator: dominic@familie-radermacher.ch\n" "Language-Team: English \n" @@ -155,137 +155,137 @@ msgstr "" msgid "debug: called ptouch_sendraster() with NULL ptdev\n" msgstr "" -#: src/ptouch-print.c:82 +#: src/ptouch-print.c:81 #, c-format msgid "nothing to print\n" msgstr "" -#: src/ptouch-print.c:90 +#: src/ptouch-print.c:89 #, c-format msgid "image is too large (%ipx x %ipx)\n" msgstr "image is too large (%ipx x %ipx)\n" -#: src/ptouch-print.c:91 +#: src/ptouch-print.c:90 #, c-format msgid "maximum printing width for this tape is %ipx\n" msgstr "maximum printing width for this tape is %ipx\n" -#: src/ptouch-print.c:94 +#: src/ptouch-print.c:93 #, fuzzy, c-format msgid "image size (%ipx x %ipx)\n" msgstr "image is too large (%ipx x %ipx)\n" -#: src/ptouch-print.c:104 +#: src/ptouch-print.c:103 #, c-format msgid "ptouch_rasterstart() failed\n" msgstr "ptouch_rasterstart() failed\n" -#: src/ptouch-print.c:110 +#: src/ptouch-print.c:109 #, c-format msgid "send print information command\n" msgstr "" -#: src/ptouch-print.c:117 +#: src/ptouch-print.c:116 #, c-format msgid "send PT-D460BT chain commands\n" msgstr "" -#: src/ptouch-print.c:122 +#: src/ptouch-print.c:121 #, c-format msgid "send PT-D460BT magic commands\n" msgstr "" -#: src/ptouch-print.c:128 +#: src/ptouch-print.c:127 #, c-format msgid "send precut command\n" msgstr "" -#: src/ptouch-print.c:139 +#: src/ptouch-print.c:138 #, c-format msgid "ptouch_sendraster() failed\n" msgstr "ptouch_sendraster() failed\n" -#: src/ptouch-print.c:188 +#: src/ptouch-print.c:187 #, c-format msgid "writing image '%s' failed\n" msgstr "writing image '%s' failed\n" -#: src/ptouch-print.c:210 +#: src/ptouch-print.c:209 #, c-format msgid "debug: o baseline offset - %d\n" msgstr "" -#: src/ptouch-print.c:211 +#: src/ptouch-print.c:210 #, c-format msgid "debug: text baseline offset - %d\n" msgstr "" -#: src/ptouch-print.c:270 +#: src/ptouch-print.c:269 #, c-format msgid "render_text(): %i lines, font = '%s'\n" msgstr "" -#: src/ptouch-print.c:273 +#: src/ptouch-print.c:272 #, c-format msgid "warning: font config not available\n" msgstr "warning: font config not available\n" -#: src/ptouch-print.c:277 +#: src/ptouch-print.c:276 #, c-format msgid "setting font size=%i\n" msgstr "setting font size=%i\n" -#: src/ptouch-print.c:281 +#: src/ptouch-print.c:280 #, c-format msgid "could not estimate needed font size\n" msgstr "could not estimate needed font size\n" -#: src/ptouch-print.c:288 +#: src/ptouch-print.c:287 #, c-format msgid "choosing font size=%i\n" msgstr "choosing font size=%i\n" -#: src/ptouch-print.c:304 src/ptouch-print.c:332 +#: src/ptouch-print.c:303 src/ptouch-print.c:331 #, c-format msgid "error in gdImageStringFT: %s\n" msgstr "error in gdImageStringFT: %s\n" -#: src/ptouch-print.c:514 +#: src/ptouch-print.c:513 #, c-format msgid "ptouch-print version %s by Dominic Radermacher\n" msgstr "ptouch-print version %s by Dominic Radermacher\n" -#: src/ptouch-print.c:553 +#: src/ptouch-print.c:552 #, c-format msgid "ptouch_init() failed\n" msgstr "ptouch_init() failed\n" -#: src/ptouch-print.c:556 +#: src/ptouch-print.c:555 #, c-format msgid "ptouch_getstatus() failed\n" msgstr "ptouch_getstatus() failed\n" -#: src/ptouch-print.c:595 +#: src/ptouch-print.c:594 #, fuzzy, c-format msgid "maximum printing width for this printer is %ldpx\n" msgstr "maximum printing width for this tape is %ipx\n" -#: src/ptouch-print.c:596 +#: src/ptouch-print.c:595 #, fuzzy, c-format msgid "maximum printing width for this tape is %ldpx\n" msgstr "maximum printing width for this tape is %ipx\n" -#: src/ptouch-print.c:608 +#: src/ptouch-print.c:607 #, c-format msgid "failed to load image file\n" msgstr "" -#: src/ptouch-print.c:624 +#: src/ptouch-print.c:623 #, c-format msgid "could not render text\n" msgstr "could not render text\n" -#: src/ptouch-print.c:659 +#: src/ptouch-print.c:658 #, c-format msgid "ptouch_finalize(%d) failed\n" msgstr "ptouch_finalize(%d) failed\n" diff --git a/po/ptouch.pot b/po/ptouch.pot index 3a4f9b5..b4e6f89 100644 --- a/po/ptouch.pot +++ b/po/ptouch.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: ptouch-print\n" "Report-Msgid-Bugs-To: dominic@familie-radermacher.ch\n" -"POT-Creation-Date: 2025-08-03 10:11+0200\n" +"POT-Creation-Date: 2025-08-10 07:19+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -153,137 +153,137 @@ msgstr "" msgid "debug: called ptouch_sendraster() with NULL ptdev\n" msgstr "" -#: src/ptouch-print.c:82 +#: src/ptouch-print.c:81 #, c-format msgid "nothing to print\n" msgstr "" -#: src/ptouch-print.c:90 +#: src/ptouch-print.c:89 #, c-format msgid "image is too large (%ipx x %ipx)\n" msgstr "" -#: src/ptouch-print.c:91 +#: src/ptouch-print.c:90 #, c-format msgid "maximum printing width for this tape is %ipx\n" msgstr "" -#: src/ptouch-print.c:94 +#: src/ptouch-print.c:93 #, c-format msgid "image size (%ipx x %ipx)\n" msgstr "" -#: src/ptouch-print.c:104 +#: src/ptouch-print.c:103 #, c-format msgid "ptouch_rasterstart() failed\n" msgstr "" -#: src/ptouch-print.c:110 +#: src/ptouch-print.c:109 #, c-format msgid "send print information command\n" msgstr "" -#: src/ptouch-print.c:117 +#: src/ptouch-print.c:116 #, c-format msgid "send PT-D460BT chain commands\n" msgstr "" -#: src/ptouch-print.c:122 +#: src/ptouch-print.c:121 #, c-format msgid "send PT-D460BT magic commands\n" msgstr "" -#: src/ptouch-print.c:128 +#: src/ptouch-print.c:127 #, c-format msgid "send precut command\n" msgstr "" -#: src/ptouch-print.c:139 +#: src/ptouch-print.c:138 #, c-format msgid "ptouch_sendraster() failed\n" msgstr "" -#: src/ptouch-print.c:188 +#: src/ptouch-print.c:187 #, c-format msgid "writing image '%s' failed\n" msgstr "" -#: src/ptouch-print.c:210 +#: src/ptouch-print.c:209 #, c-format msgid "debug: o baseline offset - %d\n" msgstr "" -#: src/ptouch-print.c:211 +#: src/ptouch-print.c:210 #, c-format msgid "debug: text baseline offset - %d\n" msgstr "" -#: src/ptouch-print.c:270 +#: src/ptouch-print.c:269 #, c-format msgid "render_text(): %i lines, font = '%s'\n" msgstr "" -#: src/ptouch-print.c:273 +#: src/ptouch-print.c:272 #, c-format msgid "warning: font config not available\n" msgstr "" -#: src/ptouch-print.c:277 +#: src/ptouch-print.c:276 #, c-format msgid "setting font size=%i\n" msgstr "" -#: src/ptouch-print.c:281 +#: src/ptouch-print.c:280 #, c-format msgid "could not estimate needed font size\n" msgstr "" -#: src/ptouch-print.c:288 +#: src/ptouch-print.c:287 #, c-format msgid "choosing font size=%i\n" msgstr "" -#: src/ptouch-print.c:304 src/ptouch-print.c:332 +#: src/ptouch-print.c:303 src/ptouch-print.c:331 #, c-format msgid "error in gdImageStringFT: %s\n" msgstr "" -#: src/ptouch-print.c:514 +#: src/ptouch-print.c:513 #, c-format msgid "ptouch-print version %s by Dominic Radermacher\n" msgstr "" -#: src/ptouch-print.c:553 +#: src/ptouch-print.c:552 #, c-format msgid "ptouch_init() failed\n" msgstr "" -#: src/ptouch-print.c:556 +#: src/ptouch-print.c:555 #, c-format msgid "ptouch_getstatus() failed\n" msgstr "" -#: src/ptouch-print.c:595 +#: src/ptouch-print.c:594 #, c-format msgid "maximum printing width for this printer is %ldpx\n" msgstr "" -#: src/ptouch-print.c:596 +#: src/ptouch-print.c:595 #, c-format msgid "maximum printing width for this tape is %ldpx\n" msgstr "" -#: src/ptouch-print.c:608 +#: src/ptouch-print.c:607 #, c-format msgid "failed to load image file\n" msgstr "" -#: src/ptouch-print.c:624 +#: src/ptouch-print.c:623 #, c-format msgid "could not render text\n" msgstr "" -#: src/ptouch-print.c:659 +#: src/ptouch-print.c:658 #, c-format msgid "ptouch_finalize(%d) failed\n" msgstr "" diff --git a/src/libptouch.c b/src/libptouch.c index 4fed15f..9d59a55 100644 --- a/src/libptouch.c +++ b/src/libptouch.c @@ -26,8 +26,8 @@ #include /* open() */ #include /* open() */ #include /* nanosleep(), struct timespec */ +#include /* gettext() */ -#include "gettext.h" /* gettext(), ngettext() */ #include "ptouch.h" #define _(s) gettext(s) diff --git a/src/ptouch-print.c b/src/ptouch-print.c index 512bfeb..cd58de6 100644 --- a/src/ptouch-print.c +++ b/src/ptouch-print.c @@ -29,7 +29,6 @@ #include /* LC_ALL */ #include "version.h" -#include "gettext.h" /* gettext(), ngettext() */ #include "ptouch.h" #define _(s) gettext(s) From f59e19349bf747d8b61fc877f9638f0ae19f87ec Mon Sep 17 00:00:00 2001 From: Frost Date: Wed, 6 Aug 2025 22:58:58 -0700 Subject: [PATCH 39/53] Print without the default length margins Brother's software may default to 0x0e, but that probably assumes you're making text labels and not printing images. For printing images you might want borderless (we certainly do), and for text labels you can always add the margins to the label before printing. This commit uses 1px length margins instead of 0 to prevent some leftover black on the edges of the next print. --- src/libptouch.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/libptouch.c b/src/libptouch.c index 9d59a55..b02e34b 100644 --- a/src/libptouch.c +++ b/src/libptouch.c @@ -228,10 +228,11 @@ int ptouch_send_d460bt_magic(ptouch_dev ptdev) uint8_t cmd[7]; /* n1 and n2 are the length margin/spacing, in px? (uint16_t value, little endian) */ /* A value of 0x06 is equivalent to the width margin on 6mm tape */ + /* A value of 0x01 adds barely any margin, suitable for image printing */ /* The default for P-Touch software is 0x0e */ /* n3 must be 0x4D or the print gets corrupted! */ /* n4 seems to be ignored or reserved. */ - memcpy(cmd, "\x1b\x69\x64\x0e\x00\x4d\x00", 7); + memcpy(cmd, "\x1b\x69\x64\x01\x00\x4d\x00", 7); return ptouch_send(ptdev, (uint8_t *)cmd, sizeof(cmd)); } From f1c34dd0d4e3bf89851f74a765ba4aca60fdfcc4 Mon Sep 17 00:00:00 2001 From: Frost Date: Wed, 6 Aug 2025 23:25:28 -0700 Subject: [PATCH 40/53] Send chain magic after precut This lets you do chain mode with a precut first. --- src/ptouch-print.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/ptouch-print.c b/src/ptouch-print.c index cd58de6..de54f1f 100644 --- a/src/ptouch-print.c +++ b/src/ptouch-print.c @@ -110,12 +110,6 @@ int print_img(ptouch_dev ptdev, gdImage *im, int chain) } } if ((ptdev->devinfo->flags & FLAG_D460BT_MAGIC) == FLAG_D460BT_MAGIC) { - if (chain) { - ptouch_send_d460bt_chain(ptdev); - if (debug) { - printf(_("send PT-D460BT chain commands\n")); - } - } ptouch_send_d460bt_magic(ptdev); if (debug) { printf(_("send PT-D460BT magic commands\n")); @@ -127,6 +121,15 @@ int print_img(ptouch_dev ptdev, gdImage *im, int chain) printf(_("send precut command\n")); } } + /* send chain command after precut, to allow precutting before chain */ + if ((ptdev->devinfo->flags & FLAG_D460BT_MAGIC) == FLAG_D460BT_MAGIC) { + if (chain) { + ptouch_send_d460bt_chain(ptdev); + if (debug) { + printf(_("send PT-D460BT chain commands\n")); + } + } + } for (int k = 0; k < gdImageSX(im); ++k) { memset(rasterline, 0, sizeof(rasterline)); for (int i = 0; i < gdImageSY(im); ++i) { From 3bcde60eeae4279a6475036aca77b74ffb2b111b Mon Sep 17 00:00:00 2001 From: Dominic Radermacher Date: Sun, 10 Aug 2025 08:28:40 +0200 Subject: [PATCH 41/53] update po files --- po/de.po | 84 +++++++++++++++++++++++++-------------------------- po/en.po | 84 +++++++++++++++++++++++++-------------------------- po/ptouch.pot | 84 +++++++++++++++++++++++++-------------------------- 3 files changed, 126 insertions(+), 126 deletions(-) diff --git a/po/de.po b/po/de.po index f095f79..5b161d4 100644 --- a/po/de.po +++ b/po/de.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: ptouch-print 1.3.1\n" "Report-Msgid-Bugs-To: dominic@familie-radermacher.ch\n" -"POT-Creation-Date: 2025-08-10 07:19+0200\n" +"POT-Creation-Date: 2025-08-10 08:23+0200\n" "PO-Revision-Date: 2024-05-23 22:27-0400\n" "Last-Translator: dominic@familie-radermacher.ch\n" "Language-Team: German \n" @@ -75,82 +75,82 @@ msgstr "" msgid "write error: could send only %i of %ld bytes\n" msgstr "Lesefehler: %i anstatt 32 bytes empfangen\n" -#: src/libptouch.c:248 +#: src/libptouch.c:249 #, c-format msgid "debug: called ptouch_info_cmd() with NULL ptdev\n" msgstr "" -#: src/libptouch.c:290 +#: src/libptouch.c:291 #, fuzzy, c-format msgid "debug: called ptouch_rasterstart() with NULL ptdev\n" msgstr "ptouch_rasterstart() fehlgeschlagen\n" -#: src/libptouch.c:321 +#: src/libptouch.c:322 #, c-format msgid "debug: called ptouch_finalize() with NULL ptdev\n" msgstr "" -#: src/libptouch.c:336 +#: src/libptouch.c:337 #, c-format msgid "debug: dumping raw status bytes\n" msgstr "" -#: src/libptouch.c:355 +#: src/libptouch.c:356 #, c-format msgid "debug: called ptouch_getstatus() with NULL ptdev\n" msgstr "" -#: src/libptouch.c:365 src/libptouch.c:401 +#: src/libptouch.c:366 src/libptouch.c:402 #, c-format msgid "read error: %s\n" msgstr "" -#: src/libptouch.c:370 +#: src/libptouch.c:371 #, c-format msgid "timeout while waiting for status response\n" msgstr "" -#: src/libptouch.c:384 +#: src/libptouch.c:385 #, c-format msgid "unknown tape width of %imm, please report this.\n" msgstr "Unbekannte Schriftband breite (%i mm), bitte melden\n" -#: src/libptouch.c:390 +#: src/libptouch.c:391 #, c-format msgid "got only 16 bytes... wondering what they are:\n" msgstr "nur 16 bytes empfangen... mal gucken was die sind:\n" -#: src/libptouch.c:394 +#: src/libptouch.c:395 #, c-format msgid "read error: got %i instead of 32 bytes\n" msgstr "Lesefehler: %i anstatt 32 bytes empfangen\n" -#: src/libptouch.c:397 +#: src/libptouch.c:398 #, c-format msgid "strange status:\n" msgstr "Seltsamer Status:\n" -#: src/libptouch.c:399 +#: src/libptouch.c:400 #, c-format msgid "trying to flush junk\n" msgstr "" -#: src/libptouch.c:404 +#: src/libptouch.c:405 #, c-format msgid "got another %i bytes. now try again\n" msgstr "weitere %i bytes empfangen. probiere es nochmal.\n" -#: src/libptouch.c:411 +#: src/libptouch.c:412 #, c-format msgid "debug: called ptouch_get_tape_width() with NULL ptdev\n" msgstr "" -#: src/libptouch.c:420 +#: src/libptouch.c:421 #, c-format msgid "debug: called ptouch_get_max_width() with NULL ptdev\n" msgstr "" -#: src/libptouch.c:432 +#: src/libptouch.c:433 #, c-format msgid "debug: called ptouch_sendraster() with NULL ptdev\n" msgstr "" @@ -185,107 +185,107 @@ msgstr "ptouch_rasterstart() fehlgeschlagen\n" msgid "send print information command\n" msgstr "" -#: src/ptouch-print.c:116 -#, c-format -msgid "send PT-D460BT chain commands\n" -msgstr "" - -#: src/ptouch-print.c:121 +#: src/ptouch-print.c:115 #, c-format msgid "send PT-D460BT magic commands\n" msgstr "" -#: src/ptouch-print.c:127 +#: src/ptouch-print.c:121 #, c-format msgid "send precut command\n" msgstr "" -#: src/ptouch-print.c:138 +#: src/ptouch-print.c:129 +#, c-format +msgid "send PT-D460BT chain commands\n" +msgstr "" + +#: src/ptouch-print.c:141 #, fuzzy, c-format msgid "ptouch_sendraster() failed\n" msgstr "ptouch_send() fehlgeschlagen\n" -#: src/ptouch-print.c:187 +#: src/ptouch-print.c:190 #, c-format msgid "writing image '%s' failed\n" msgstr "Schreiben der Bilddatei '%s' fehlgeschlagen\n" -#: src/ptouch-print.c:209 +#: src/ptouch-print.c:212 #, c-format msgid "debug: o baseline offset - %d\n" msgstr "" -#: src/ptouch-print.c:210 +#: src/ptouch-print.c:213 #, c-format msgid "debug: text baseline offset - %d\n" msgstr "" -#: src/ptouch-print.c:269 +#: src/ptouch-print.c:272 #, c-format msgid "render_text(): %i lines, font = '%s'\n" msgstr "" -#: src/ptouch-print.c:272 +#: src/ptouch-print.c:275 #, c-format msgid "warning: font config not available\n" msgstr "Warnung: fontconfig ist nicht verfügbar\n" -#: src/ptouch-print.c:276 +#: src/ptouch-print.c:279 #, c-format msgid "setting font size=%i\n" msgstr "setze Zeichensatzgrösse=%i\n" -#: src/ptouch-print.c:280 +#: src/ptouch-print.c:283 #, c-format msgid "could not estimate needed font size\n" msgstr "Konnte die notwendige Zeichensatzgrösse nicht bestimmen\n" -#: src/ptouch-print.c:287 +#: src/ptouch-print.c:290 #, c-format msgid "choosing font size=%i\n" msgstr "Wähle Zeichensatzgrösse %i\n" -#: src/ptouch-print.c:303 src/ptouch-print.c:331 +#: src/ptouch-print.c:306 src/ptouch-print.c:334 #, c-format msgid "error in gdImageStringFT: %s\n" msgstr "Fehler in Funktion gdImageStringFT(): %s\n" -#: src/ptouch-print.c:513 +#: src/ptouch-print.c:516 #, c-format msgid "ptouch-print version %s by Dominic Radermacher\n" msgstr "ptouch-print Version %s von Dominic Radermacher\n" -#: src/ptouch-print.c:552 +#: src/ptouch-print.c:555 #, c-format msgid "ptouch_init() failed\n" msgstr "ptouch_init() fehlgeschlagen\n" -#: src/ptouch-print.c:555 +#: src/ptouch-print.c:558 #, c-format msgid "ptouch_getstatus() failed\n" msgstr "ptouch_getstatus() fehlgeschlagen\n" -#: src/ptouch-print.c:594 +#: src/ptouch-print.c:597 #, fuzzy, c-format msgid "maximum printing width for this printer is %ldpx\n" msgstr "Maximal druckbare Breite für dieses Schriftband sind %ipx\n" -#: src/ptouch-print.c:595 +#: src/ptouch-print.c:598 #, fuzzy, c-format msgid "maximum printing width for this tape is %ldpx\n" msgstr "Maximal druckbare Breite für dieses Schriftband sind %ipx\n" -#: src/ptouch-print.c:607 +#: src/ptouch-print.c:610 #, c-format msgid "failed to load image file\n" msgstr "" -#: src/ptouch-print.c:623 +#: src/ptouch-print.c:626 #, c-format msgid "could not render text\n" msgstr "Konnte Text nicht rendern\n" -#: src/ptouch-print.c:658 +#: src/ptouch-print.c:661 #, c-format msgid "ptouch_finalize(%d) failed\n" msgstr "ptouch_finalize(%d) fehlgeschlagen\n" diff --git a/po/en.po b/po/en.po index 99ad1fe..92b7c69 100644 --- a/po/en.po +++ b/po/en.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: ptouch-print 1.3.1\n" "Report-Msgid-Bugs-To: dominic@familie-radermacher.ch\n" -"POT-Creation-Date: 2025-08-10 07:19+0200\n" +"POT-Creation-Date: 2025-08-10 08:23+0200\n" "PO-Revision-Date: 2024-05-23 22:26-0400\n" "Last-Translator: dominic@familie-radermacher.ch\n" "Language-Team: English \n" @@ -75,82 +75,82 @@ msgstr "write error: %s\n" msgid "write error: could send only %i of %ld bytes\n" msgstr "write error: could send only %i of %i bytes\n" -#: src/libptouch.c:248 +#: src/libptouch.c:249 #, c-format msgid "debug: called ptouch_info_cmd() with NULL ptdev\n" msgstr "" -#: src/libptouch.c:290 +#: src/libptouch.c:291 #, fuzzy, c-format msgid "debug: called ptouch_rasterstart() with NULL ptdev\n" msgstr "ptouch_rasterstart() failed\n" -#: src/libptouch.c:321 +#: src/libptouch.c:322 #, c-format msgid "debug: called ptouch_finalize() with NULL ptdev\n" msgstr "" -#: src/libptouch.c:336 +#: src/libptouch.c:337 #, c-format msgid "debug: dumping raw status bytes\n" msgstr "debug: dumping raw status bytes\n" -#: src/libptouch.c:355 +#: src/libptouch.c:356 #, c-format msgid "debug: called ptouch_getstatus() with NULL ptdev\n" msgstr "" -#: src/libptouch.c:365 src/libptouch.c:401 +#: src/libptouch.c:366 src/libptouch.c:402 #, c-format msgid "read error: %s\n" msgstr "read error: %s\n" -#: src/libptouch.c:370 +#: src/libptouch.c:371 #, c-format msgid "timeout while waiting for status response\n" msgstr "timeout while waiting for status response\n" -#: src/libptouch.c:384 +#: src/libptouch.c:385 #, c-format msgid "unknown tape width of %imm, please report this.\n" msgstr "unknown tape width of %imm, please report this.\n" -#: src/libptouch.c:390 +#: src/libptouch.c:391 #, c-format msgid "got only 16 bytes... wondering what they are:\n" msgstr "got only 16 bytes... wondering what they are:\n" -#: src/libptouch.c:394 +#: src/libptouch.c:395 #, c-format msgid "read error: got %i instead of 32 bytes\n" msgstr "read error: got %i instead of 32 bytes\n" -#: src/libptouch.c:397 +#: src/libptouch.c:398 #, c-format msgid "strange status:\n" msgstr "strange status:\n" -#: src/libptouch.c:399 +#: src/libptouch.c:400 #, c-format msgid "trying to flush junk\n" msgstr "trying to flush junk\n" -#: src/libptouch.c:404 +#: src/libptouch.c:405 #, c-format msgid "got another %i bytes. now try again\n" msgstr "got another %i bytes. now try again\n" -#: src/libptouch.c:411 +#: src/libptouch.c:412 #, c-format msgid "debug: called ptouch_get_tape_width() with NULL ptdev\n" msgstr "" -#: src/libptouch.c:420 +#: src/libptouch.c:421 #, c-format msgid "debug: called ptouch_get_max_width() with NULL ptdev\n" msgstr "" -#: src/libptouch.c:432 +#: src/libptouch.c:433 #, c-format msgid "debug: called ptouch_sendraster() with NULL ptdev\n" msgstr "" @@ -185,107 +185,107 @@ msgstr "ptouch_rasterstart() failed\n" msgid "send print information command\n" msgstr "" -#: src/ptouch-print.c:116 -#, c-format -msgid "send PT-D460BT chain commands\n" -msgstr "" - -#: src/ptouch-print.c:121 +#: src/ptouch-print.c:115 #, c-format msgid "send PT-D460BT magic commands\n" msgstr "" -#: src/ptouch-print.c:127 +#: src/ptouch-print.c:121 #, c-format msgid "send precut command\n" msgstr "" -#: src/ptouch-print.c:138 +#: src/ptouch-print.c:129 +#, c-format +msgid "send PT-D460BT chain commands\n" +msgstr "" + +#: src/ptouch-print.c:141 #, c-format msgid "ptouch_sendraster() failed\n" msgstr "ptouch_sendraster() failed\n" -#: src/ptouch-print.c:187 +#: src/ptouch-print.c:190 #, c-format msgid "writing image '%s' failed\n" msgstr "writing image '%s' failed\n" -#: src/ptouch-print.c:209 +#: src/ptouch-print.c:212 #, c-format msgid "debug: o baseline offset - %d\n" msgstr "" -#: src/ptouch-print.c:210 +#: src/ptouch-print.c:213 #, c-format msgid "debug: text baseline offset - %d\n" msgstr "" -#: src/ptouch-print.c:269 +#: src/ptouch-print.c:272 #, c-format msgid "render_text(): %i lines, font = '%s'\n" msgstr "" -#: src/ptouch-print.c:272 +#: src/ptouch-print.c:275 #, c-format msgid "warning: font config not available\n" msgstr "warning: font config not available\n" -#: src/ptouch-print.c:276 +#: src/ptouch-print.c:279 #, c-format msgid "setting font size=%i\n" msgstr "setting font size=%i\n" -#: src/ptouch-print.c:280 +#: src/ptouch-print.c:283 #, c-format msgid "could not estimate needed font size\n" msgstr "could not estimate needed font size\n" -#: src/ptouch-print.c:287 +#: src/ptouch-print.c:290 #, c-format msgid "choosing font size=%i\n" msgstr "choosing font size=%i\n" -#: src/ptouch-print.c:303 src/ptouch-print.c:331 +#: src/ptouch-print.c:306 src/ptouch-print.c:334 #, c-format msgid "error in gdImageStringFT: %s\n" msgstr "error in gdImageStringFT: %s\n" -#: src/ptouch-print.c:513 +#: src/ptouch-print.c:516 #, c-format msgid "ptouch-print version %s by Dominic Radermacher\n" msgstr "ptouch-print version %s by Dominic Radermacher\n" -#: src/ptouch-print.c:552 +#: src/ptouch-print.c:555 #, c-format msgid "ptouch_init() failed\n" msgstr "ptouch_init() failed\n" -#: src/ptouch-print.c:555 +#: src/ptouch-print.c:558 #, c-format msgid "ptouch_getstatus() failed\n" msgstr "ptouch_getstatus() failed\n" -#: src/ptouch-print.c:594 +#: src/ptouch-print.c:597 #, fuzzy, c-format msgid "maximum printing width for this printer is %ldpx\n" msgstr "maximum printing width for this tape is %ipx\n" -#: src/ptouch-print.c:595 +#: src/ptouch-print.c:598 #, fuzzy, c-format msgid "maximum printing width for this tape is %ldpx\n" msgstr "maximum printing width for this tape is %ipx\n" -#: src/ptouch-print.c:607 +#: src/ptouch-print.c:610 #, c-format msgid "failed to load image file\n" msgstr "" -#: src/ptouch-print.c:623 +#: src/ptouch-print.c:626 #, c-format msgid "could not render text\n" msgstr "could not render text\n" -#: src/ptouch-print.c:658 +#: src/ptouch-print.c:661 #, c-format msgid "ptouch_finalize(%d) failed\n" msgstr "ptouch_finalize(%d) failed\n" diff --git a/po/ptouch.pot b/po/ptouch.pot index b4e6f89..5d9b6e1 100644 --- a/po/ptouch.pot +++ b/po/ptouch.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: ptouch-print\n" "Report-Msgid-Bugs-To: dominic@familie-radermacher.ch\n" -"POT-Creation-Date: 2025-08-10 07:19+0200\n" +"POT-Creation-Date: 2025-08-10 08:23+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -73,82 +73,82 @@ msgstr "" msgid "write error: could send only %i of %ld bytes\n" msgstr "" -#: src/libptouch.c:248 +#: src/libptouch.c:249 #, c-format msgid "debug: called ptouch_info_cmd() with NULL ptdev\n" msgstr "" -#: src/libptouch.c:290 +#: src/libptouch.c:291 #, c-format msgid "debug: called ptouch_rasterstart() with NULL ptdev\n" msgstr "" -#: src/libptouch.c:321 +#: src/libptouch.c:322 #, c-format msgid "debug: called ptouch_finalize() with NULL ptdev\n" msgstr "" -#: src/libptouch.c:336 +#: src/libptouch.c:337 #, c-format msgid "debug: dumping raw status bytes\n" msgstr "" -#: src/libptouch.c:355 +#: src/libptouch.c:356 #, c-format msgid "debug: called ptouch_getstatus() with NULL ptdev\n" msgstr "" -#: src/libptouch.c:365 src/libptouch.c:401 +#: src/libptouch.c:366 src/libptouch.c:402 #, c-format msgid "read error: %s\n" msgstr "" -#: src/libptouch.c:370 +#: src/libptouch.c:371 #, c-format msgid "timeout while waiting for status response\n" msgstr "" -#: src/libptouch.c:384 +#: src/libptouch.c:385 #, c-format msgid "unknown tape width of %imm, please report this.\n" msgstr "" -#: src/libptouch.c:390 +#: src/libptouch.c:391 #, c-format msgid "got only 16 bytes... wondering what they are:\n" msgstr "" -#: src/libptouch.c:394 +#: src/libptouch.c:395 #, c-format msgid "read error: got %i instead of 32 bytes\n" msgstr "" -#: src/libptouch.c:397 +#: src/libptouch.c:398 #, c-format msgid "strange status:\n" msgstr "" -#: src/libptouch.c:399 +#: src/libptouch.c:400 #, c-format msgid "trying to flush junk\n" msgstr "" -#: src/libptouch.c:404 +#: src/libptouch.c:405 #, c-format msgid "got another %i bytes. now try again\n" msgstr "" -#: src/libptouch.c:411 +#: src/libptouch.c:412 #, c-format msgid "debug: called ptouch_get_tape_width() with NULL ptdev\n" msgstr "" -#: src/libptouch.c:420 +#: src/libptouch.c:421 #, c-format msgid "debug: called ptouch_get_max_width() with NULL ptdev\n" msgstr "" -#: src/libptouch.c:432 +#: src/libptouch.c:433 #, c-format msgid "debug: called ptouch_sendraster() with NULL ptdev\n" msgstr "" @@ -183,107 +183,107 @@ msgstr "" msgid "send print information command\n" msgstr "" -#: src/ptouch-print.c:116 -#, c-format -msgid "send PT-D460BT chain commands\n" -msgstr "" - -#: src/ptouch-print.c:121 +#: src/ptouch-print.c:115 #, c-format msgid "send PT-D460BT magic commands\n" msgstr "" -#: src/ptouch-print.c:127 +#: src/ptouch-print.c:121 #, c-format msgid "send precut command\n" msgstr "" -#: src/ptouch-print.c:138 +#: src/ptouch-print.c:129 +#, c-format +msgid "send PT-D460BT chain commands\n" +msgstr "" + +#: src/ptouch-print.c:141 #, c-format msgid "ptouch_sendraster() failed\n" msgstr "" -#: src/ptouch-print.c:187 +#: src/ptouch-print.c:190 #, c-format msgid "writing image '%s' failed\n" msgstr "" -#: src/ptouch-print.c:209 +#: src/ptouch-print.c:212 #, c-format msgid "debug: o baseline offset - %d\n" msgstr "" -#: src/ptouch-print.c:210 +#: src/ptouch-print.c:213 #, c-format msgid "debug: text baseline offset - %d\n" msgstr "" -#: src/ptouch-print.c:269 +#: src/ptouch-print.c:272 #, c-format msgid "render_text(): %i lines, font = '%s'\n" msgstr "" -#: src/ptouch-print.c:272 +#: src/ptouch-print.c:275 #, c-format msgid "warning: font config not available\n" msgstr "" -#: src/ptouch-print.c:276 +#: src/ptouch-print.c:279 #, c-format msgid "setting font size=%i\n" msgstr "" -#: src/ptouch-print.c:280 +#: src/ptouch-print.c:283 #, c-format msgid "could not estimate needed font size\n" msgstr "" -#: src/ptouch-print.c:287 +#: src/ptouch-print.c:290 #, c-format msgid "choosing font size=%i\n" msgstr "" -#: src/ptouch-print.c:303 src/ptouch-print.c:331 +#: src/ptouch-print.c:306 src/ptouch-print.c:334 #, c-format msgid "error in gdImageStringFT: %s\n" msgstr "" -#: src/ptouch-print.c:513 +#: src/ptouch-print.c:516 #, c-format msgid "ptouch-print version %s by Dominic Radermacher\n" msgstr "" -#: src/ptouch-print.c:552 +#: src/ptouch-print.c:555 #, c-format msgid "ptouch_init() failed\n" msgstr "" -#: src/ptouch-print.c:555 +#: src/ptouch-print.c:558 #, c-format msgid "ptouch_getstatus() failed\n" msgstr "" -#: src/ptouch-print.c:594 +#: src/ptouch-print.c:597 #, c-format msgid "maximum printing width for this printer is %ldpx\n" msgstr "" -#: src/ptouch-print.c:595 +#: src/ptouch-print.c:598 #, c-format msgid "maximum printing width for this tape is %ldpx\n" msgstr "" -#: src/ptouch-print.c:607 +#: src/ptouch-print.c:610 #, c-format msgid "failed to load image file\n" msgstr "" -#: src/ptouch-print.c:623 +#: src/ptouch-print.c:626 #, c-format msgid "could not render text\n" msgstr "" -#: src/ptouch-print.c:658 +#: src/ptouch-print.c:661 #, c-format msgid "ptouch_finalize(%d) failed\n" msgstr "" From 92c1e43f0c7c808a18cf9fbe8eace360ecd375b6 Mon Sep 17 00:00:00 2001 From: Michael Schulz Date: Mon, 11 Aug 2025 09:49:18 +0200 Subject: [PATCH 42/53] improved argv parser, enable printing of text starting with a dash --- po/de.po | 76 +++++--- po/en.po | 76 +++++--- po/ptouch.pot | 90 +++++---- src/ptouch-print.c | 467 ++++++++++++++++++++++++--------------------- 4 files changed, 396 insertions(+), 313 deletions(-) diff --git a/po/de.po b/po/de.po index 5b161d4..e54c3f4 100644 --- a/po/de.po +++ b/po/de.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: ptouch-print 1.3.1\n" "Report-Msgid-Bugs-To: dominic@familie-radermacher.ch\n" -"POT-Creation-Date: 2025-08-10 08:23+0200\n" +"POT-Creation-Date: 2025-08-11 09:46+0200\n" "PO-Revision-Date: 2024-05-23 22:27-0400\n" "Last-Translator: dominic@familie-radermacher.ch\n" "Language-Team: German \n" @@ -155,141 +155,157 @@ msgstr "" msgid "debug: called ptouch_sendraster() with NULL ptdev\n" msgstr "" -#: src/ptouch-print.c:81 +#: src/ptouch-print.c:143 #, c-format msgid "nothing to print\n" msgstr "" -#: src/ptouch-print.c:89 +#: src/ptouch-print.c:151 #, c-format msgid "image is too large (%ipx x %ipx)\n" msgstr "Bild ist zu gross (%ipx x %ipx)\n" -#: src/ptouch-print.c:90 +#: src/ptouch-print.c:152 #, c-format msgid "maximum printing width for this tape is %ipx\n" msgstr "Maximal druckbare Breite für dieses Schriftband sind %ipx\n" -#: src/ptouch-print.c:93 +#: src/ptouch-print.c:155 #, fuzzy, c-format msgid "image size (%ipx x %ipx)\n" msgstr "Bild ist zu gross (%ipx x %ipx)\n" -#: src/ptouch-print.c:103 +#: src/ptouch-print.c:165 #, c-format msgid "ptouch_rasterstart() failed\n" msgstr "ptouch_rasterstart() fehlgeschlagen\n" -#: src/ptouch-print.c:109 +#: src/ptouch-print.c:171 #, c-format msgid "send print information command\n" msgstr "" -#: src/ptouch-print.c:115 +#: src/ptouch-print.c:177 #, c-format msgid "send PT-D460BT magic commands\n" msgstr "" -#: src/ptouch-print.c:121 +#: src/ptouch-print.c:183 #, c-format msgid "send precut command\n" msgstr "" -#: src/ptouch-print.c:129 +#: src/ptouch-print.c:191 #, c-format msgid "send PT-D460BT chain commands\n" msgstr "" -#: src/ptouch-print.c:141 +#: src/ptouch-print.c:203 #, fuzzy, c-format msgid "ptouch_sendraster() failed\n" msgstr "ptouch_send() fehlgeschlagen\n" -#: src/ptouch-print.c:190 +#: src/ptouch-print.c:252 #, c-format msgid "writing image '%s' failed\n" msgstr "Schreiben der Bilddatei '%s' fehlgeschlagen\n" -#: src/ptouch-print.c:212 +#: src/ptouch-print.c:274 #, c-format msgid "debug: o baseline offset - %d\n" msgstr "" -#: src/ptouch-print.c:213 +#: src/ptouch-print.c:275 #, c-format msgid "debug: text baseline offset - %d\n" msgstr "" -#: src/ptouch-print.c:272 +#: src/ptouch-print.c:334 #, c-format msgid "render_text(): %i lines, font = '%s'\n" msgstr "" -#: src/ptouch-print.c:275 +#: src/ptouch-print.c:337 #, c-format msgid "warning: font config not available\n" msgstr "Warnung: fontconfig ist nicht verfügbar\n" -#: src/ptouch-print.c:279 +#: src/ptouch-print.c:341 #, c-format msgid "setting font size=%i\n" msgstr "setze Zeichensatzgrösse=%i\n" -#: src/ptouch-print.c:283 +#: src/ptouch-print.c:345 #, c-format msgid "could not estimate needed font size\n" msgstr "Konnte die notwendige Zeichensatzgrösse nicht bestimmen\n" -#: src/ptouch-print.c:290 +#: src/ptouch-print.c:352 #, c-format msgid "choosing font size=%i\n" msgstr "Wähle Zeichensatzgrösse %i\n" -#: src/ptouch-print.c:306 src/ptouch-print.c:334 +#: src/ptouch-print.c:368 src/ptouch-print.c:396 #, c-format msgid "error in gdImageStringFT: %s\n" msgstr "Fehler in Funktion gdImageStringFT(): %s\n" -#: src/ptouch-print.c:516 +#: src/ptouch-print.c:557 #, c-format -msgid "ptouch-print version %s by Dominic Radermacher\n" -msgstr "ptouch-print Version %s von Dominic Radermacher\n" +msgid "Only up to %d lines are supported" +msgstr "" -#: src/ptouch-print.c:555 +#: src/ptouch-print.c:570 +msgid "No arguments supported" +msgstr "" + +#: src/ptouch-print.c:575 +msgid "Option --writepng missing" +msgstr "" + +#: src/ptouch-print.c:578 +msgid "Options --force_tape_width and --info can't be used together" +msgstr "" + +#: src/ptouch-print.c:610 #, c-format msgid "ptouch_init() failed\n" msgstr "ptouch_init() fehlgeschlagen\n" -#: src/ptouch-print.c:558 +#: src/ptouch-print.c:613 #, c-format msgid "ptouch_getstatus() failed\n" msgstr "ptouch_getstatus() fehlgeschlagen\n" -#: src/ptouch-print.c:597 +#: src/ptouch-print.c:627 #, fuzzy, c-format msgid "maximum printing width for this printer is %ldpx\n" msgstr "Maximal druckbare Breite für dieses Schriftband sind %ipx\n" -#: src/ptouch-print.c:598 +#: src/ptouch-print.c:628 #, fuzzy, c-format msgid "maximum printing width for this tape is %ldpx\n" msgstr "Maximal druckbare Breite für dieses Schriftband sind %ipx\n" -#: src/ptouch-print.c:610 +#: src/ptouch-print.c:652 #, c-format msgid "failed to load image file\n" msgstr "" -#: src/ptouch-print.c:626 +#: src/ptouch-print.c:661 #, c-format msgid "could not render text\n" msgstr "Konnte Text nicht rendern\n" -#: src/ptouch-print.c:661 +#: src/ptouch-print.c:700 #, c-format msgid "ptouch_finalize(%d) failed\n" msgstr "ptouch_finalize(%d) fehlgeschlagen\n" +#, c-format +#~ msgid "ptouch-print version %s by Dominic Radermacher\n" +#~ msgstr "ptouch-print Version %s von Dominic Radermacher\n" + #, c-format #~ msgid "Error 1 = %02x\n" #~ msgstr "Fehlerbyte1 = %02x\n" diff --git a/po/en.po b/po/en.po index 92b7c69..c6eb2d8 100644 --- a/po/en.po +++ b/po/en.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: ptouch-print 1.3.1\n" "Report-Msgid-Bugs-To: dominic@familie-radermacher.ch\n" -"POT-Creation-Date: 2025-08-10 08:23+0200\n" +"POT-Creation-Date: 2025-08-11 09:46+0200\n" "PO-Revision-Date: 2024-05-23 22:26-0400\n" "Last-Translator: dominic@familie-radermacher.ch\n" "Language-Team: English \n" @@ -155,141 +155,157 @@ msgstr "" msgid "debug: called ptouch_sendraster() with NULL ptdev\n" msgstr "" -#: src/ptouch-print.c:81 +#: src/ptouch-print.c:143 #, c-format msgid "nothing to print\n" msgstr "" -#: src/ptouch-print.c:89 +#: src/ptouch-print.c:151 #, c-format msgid "image is too large (%ipx x %ipx)\n" msgstr "image is too large (%ipx x %ipx)\n" -#: src/ptouch-print.c:90 +#: src/ptouch-print.c:152 #, c-format msgid "maximum printing width for this tape is %ipx\n" msgstr "maximum printing width for this tape is %ipx\n" -#: src/ptouch-print.c:93 +#: src/ptouch-print.c:155 #, fuzzy, c-format msgid "image size (%ipx x %ipx)\n" msgstr "image is too large (%ipx x %ipx)\n" -#: src/ptouch-print.c:103 +#: src/ptouch-print.c:165 #, c-format msgid "ptouch_rasterstart() failed\n" msgstr "ptouch_rasterstart() failed\n" -#: src/ptouch-print.c:109 +#: src/ptouch-print.c:171 #, c-format msgid "send print information command\n" msgstr "" -#: src/ptouch-print.c:115 +#: src/ptouch-print.c:177 #, c-format msgid "send PT-D460BT magic commands\n" msgstr "" -#: src/ptouch-print.c:121 +#: src/ptouch-print.c:183 #, c-format msgid "send precut command\n" msgstr "" -#: src/ptouch-print.c:129 +#: src/ptouch-print.c:191 #, c-format msgid "send PT-D460BT chain commands\n" msgstr "" -#: src/ptouch-print.c:141 +#: src/ptouch-print.c:203 #, c-format msgid "ptouch_sendraster() failed\n" msgstr "ptouch_sendraster() failed\n" -#: src/ptouch-print.c:190 +#: src/ptouch-print.c:252 #, c-format msgid "writing image '%s' failed\n" msgstr "writing image '%s' failed\n" -#: src/ptouch-print.c:212 +#: src/ptouch-print.c:274 #, c-format msgid "debug: o baseline offset - %d\n" msgstr "" -#: src/ptouch-print.c:213 +#: src/ptouch-print.c:275 #, c-format msgid "debug: text baseline offset - %d\n" msgstr "" -#: src/ptouch-print.c:272 +#: src/ptouch-print.c:334 #, c-format msgid "render_text(): %i lines, font = '%s'\n" msgstr "" -#: src/ptouch-print.c:275 +#: src/ptouch-print.c:337 #, c-format msgid "warning: font config not available\n" msgstr "warning: font config not available\n" -#: src/ptouch-print.c:279 +#: src/ptouch-print.c:341 #, c-format msgid "setting font size=%i\n" msgstr "setting font size=%i\n" -#: src/ptouch-print.c:283 +#: src/ptouch-print.c:345 #, c-format msgid "could not estimate needed font size\n" msgstr "could not estimate needed font size\n" -#: src/ptouch-print.c:290 +#: src/ptouch-print.c:352 #, c-format msgid "choosing font size=%i\n" msgstr "choosing font size=%i\n" -#: src/ptouch-print.c:306 src/ptouch-print.c:334 +#: src/ptouch-print.c:368 src/ptouch-print.c:396 #, c-format msgid "error in gdImageStringFT: %s\n" msgstr "error in gdImageStringFT: %s\n" -#: src/ptouch-print.c:516 +#: src/ptouch-print.c:557 #, c-format -msgid "ptouch-print version %s by Dominic Radermacher\n" -msgstr "ptouch-print version %s by Dominic Radermacher\n" +msgid "Only up to %d lines are supported" +msgstr "" -#: src/ptouch-print.c:555 +#: src/ptouch-print.c:570 +msgid "No arguments supported" +msgstr "" + +#: src/ptouch-print.c:575 +msgid "Option --writepng missing" +msgstr "" + +#: src/ptouch-print.c:578 +msgid "Options --force_tape_width and --info can't be used together" +msgstr "" + +#: src/ptouch-print.c:610 #, c-format msgid "ptouch_init() failed\n" msgstr "ptouch_init() failed\n" -#: src/ptouch-print.c:558 +#: src/ptouch-print.c:613 #, c-format msgid "ptouch_getstatus() failed\n" msgstr "ptouch_getstatus() failed\n" -#: src/ptouch-print.c:597 +#: src/ptouch-print.c:627 #, fuzzy, c-format msgid "maximum printing width for this printer is %ldpx\n" msgstr "maximum printing width for this tape is %ipx\n" -#: src/ptouch-print.c:598 +#: src/ptouch-print.c:628 #, fuzzy, c-format msgid "maximum printing width for this tape is %ldpx\n" msgstr "maximum printing width for this tape is %ipx\n" -#: src/ptouch-print.c:610 +#: src/ptouch-print.c:652 #, c-format msgid "failed to load image file\n" msgstr "" -#: src/ptouch-print.c:626 +#: src/ptouch-print.c:661 #, c-format msgid "could not render text\n" msgstr "could not render text\n" -#: src/ptouch-print.c:661 +#: src/ptouch-print.c:700 #, c-format msgid "ptouch_finalize(%d) failed\n" msgstr "ptouch_finalize(%d) failed\n" +#, c-format +#~ msgid "ptouch-print version %s by Dominic Radermacher\n" +#~ msgstr "ptouch-print version %s by Dominic Radermacher\n" + #, c-format #~ msgid "Error 1 = %02x\n" #~ msgstr "Error 1 = %02x\n" diff --git a/po/ptouch.pot b/po/ptouch.pot index 5d9b6e1..d7ac264 100644 --- a/po/ptouch.pot +++ b/po/ptouch.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: ptouch-print\n" "Report-Msgid-Bugs-To: dominic@familie-radermacher.ch\n" -"POT-Creation-Date: 2025-08-10 08:23+0200\n" +"POT-Creation-Date: 2025-08-11 09:46+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -153,137 +153,149 @@ msgstr "" msgid "debug: called ptouch_sendraster() with NULL ptdev\n" msgstr "" -#: src/ptouch-print.c:81 +#: src/ptouch-print.c:143 #, c-format msgid "nothing to print\n" msgstr "" -#: src/ptouch-print.c:89 +#: src/ptouch-print.c:151 #, c-format msgid "image is too large (%ipx x %ipx)\n" msgstr "" -#: src/ptouch-print.c:90 +#: src/ptouch-print.c:152 #, c-format msgid "maximum printing width for this tape is %ipx\n" msgstr "" -#: src/ptouch-print.c:93 +#: src/ptouch-print.c:155 #, c-format msgid "image size (%ipx x %ipx)\n" msgstr "" -#: src/ptouch-print.c:103 +#: src/ptouch-print.c:165 #, c-format msgid "ptouch_rasterstart() failed\n" msgstr "" -#: src/ptouch-print.c:109 +#: src/ptouch-print.c:171 #, c-format msgid "send print information command\n" msgstr "" -#: src/ptouch-print.c:115 +#: src/ptouch-print.c:177 #, c-format msgid "send PT-D460BT magic commands\n" msgstr "" -#: src/ptouch-print.c:121 +#: src/ptouch-print.c:183 #, c-format msgid "send precut command\n" msgstr "" -#: src/ptouch-print.c:129 +#: src/ptouch-print.c:191 #, c-format msgid "send PT-D460BT chain commands\n" msgstr "" -#: src/ptouch-print.c:141 +#: src/ptouch-print.c:203 #, c-format msgid "ptouch_sendraster() failed\n" msgstr "" -#: src/ptouch-print.c:190 +#: src/ptouch-print.c:252 #, c-format msgid "writing image '%s' failed\n" msgstr "" -#: src/ptouch-print.c:212 +#: src/ptouch-print.c:274 #, c-format msgid "debug: o baseline offset - %d\n" msgstr "" -#: src/ptouch-print.c:213 +#: src/ptouch-print.c:275 #, c-format msgid "debug: text baseline offset - %d\n" msgstr "" -#: src/ptouch-print.c:272 +#: src/ptouch-print.c:334 #, c-format msgid "render_text(): %i lines, font = '%s'\n" msgstr "" -#: src/ptouch-print.c:275 +#: src/ptouch-print.c:337 #, c-format msgid "warning: font config not available\n" msgstr "" -#: src/ptouch-print.c:279 +#: src/ptouch-print.c:341 #, c-format msgid "setting font size=%i\n" msgstr "" -#: src/ptouch-print.c:283 +#: src/ptouch-print.c:345 #, c-format msgid "could not estimate needed font size\n" msgstr "" -#: src/ptouch-print.c:290 +#: src/ptouch-print.c:352 #, c-format msgid "choosing font size=%i\n" msgstr "" -#: src/ptouch-print.c:306 src/ptouch-print.c:334 +#: src/ptouch-print.c:368 src/ptouch-print.c:396 #, c-format msgid "error in gdImageStringFT: %s\n" msgstr "" -#: src/ptouch-print.c:516 +#: src/ptouch-print.c:557 #, c-format -msgid "ptouch-print version %s by Dominic Radermacher\n" +msgid "Only up to %d lines are supported" msgstr "" -#: src/ptouch-print.c:555 -#, c-format -msgid "ptouch_init() failed\n" +#: src/ptouch-print.c:570 +msgid "No arguments supported" msgstr "" -#: src/ptouch-print.c:558 -#, c-format -msgid "ptouch_getstatus() failed\n" +#: src/ptouch-print.c:575 +msgid "Option --writepng missing" msgstr "" -#: src/ptouch-print.c:597 -#, c-format -msgid "maximum printing width for this printer is %ldpx\n" -msgstr "" - -#: src/ptouch-print.c:598 -#, c-format -msgid "maximum printing width for this tape is %ldpx\n" +#: src/ptouch-print.c:578 +msgid "Options --force_tape_width and --info can't be used together" msgstr "" #: src/ptouch-print.c:610 #, c-format -msgid "failed to load image file\n" +msgid "ptouch_init() failed\n" msgstr "" -#: src/ptouch-print.c:626 +#: src/ptouch-print.c:613 #, c-format -msgid "could not render text\n" +msgid "ptouch_getstatus() failed\n" +msgstr "" + +#: src/ptouch-print.c:627 +#, c-format +msgid "maximum printing width for this printer is %ldpx\n" +msgstr "" + +#: src/ptouch-print.c:628 +#, c-format +msgid "maximum printing width for this tape is %ldpx\n" +msgstr "" + +#: src/ptouch-print.c:652 +#, c-format +msgid "failed to load image file\n" msgstr "" #: src/ptouch-print.c:661 #, c-format +msgid "could not render text\n" +msgstr "" + +#: src/ptouch-print.c:700 +#, c-format msgid "ptouch_finalize(%d) failed\n" msgstr "" diff --git a/src/ptouch-print.c b/src/ptouch-print.c index de54f1f..5f75451 100644 --- a/src/ptouch-print.c +++ b/src/ptouch-print.c @@ -17,6 +17,7 @@ Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include #include /* printf() */ #include /* exit(), malloc() */ #include @@ -35,6 +36,29 @@ #define MAX_LINES 4 /* maybe this should depend on tape size */ +#define P_NAME "ptouch-print" + +struct arguments { + bool chain; + int copies; + bool debug; + bool info; + char *font_file; + int font_size; + int forced_tape_width; + char *save_png; + int verbose; +}; + +typedef enum { JOB_CUTMARK, JOB_IMAGE, JOB_PAD, JOB_TEXT, JOB_UNDEFINED } job_type_t; + +typedef struct job { + job_type_t type; + int n; + char *lines[MAX_LINES]; + struct job *next; +} job_t; + gdImage *image_load(const char *file); void rasterline_setpixel(uint8_t* rasterline, size_t size, int pixel); int get_baselineoffset(char *text, char *font, int fsz); @@ -46,18 +70,56 @@ gdImage *img_append(gdImage *in_1, gdImage *in_2); gdImage *img_cutmark(int print_width); gdImage *render_text(char *font, char *line[], int lines, int print_width); void unsupported_printer(ptouch_dev ptdev); -void usage(char *progname); -int parse_args(int argc, char **argv); +void add_job(job_type_t type, int n, char *line); +static error_t parse_opt(int key, char *arg, struct argp_state *state); -// char *font_file = "/usr/share/fonts/TTF/Ubuntu-M.ttf"; -// char *font_file = "Ubuntu:medium"; -char *font_file = "DejaVuSans"; -char *save_png = NULL; -int verbose = 0; -int fontsize = 0; -bool debug = false; -bool chain = false; -int forced_tape_width = 0; +const char *argp_program_version = P_NAME " " VERSION; +const char *argp_program_bug_address = "Dominic Radermacher "; +static char doc[] = "ptouch-print is a command line tool to print labels on Brother P-Touch printers on Linux."; +static char args_doc[] = ""; + +static struct argp_option options[] = { + // name, key, arg, flags, doc, group + { 0, 0, 0, 0, "options:", 1}, + { "debug", 1, 0, 0, "Enable debug output", 1}, + { "font", 2, "", 0, "Use font or ", 1}, + { "fontsize", 3, "", 0, "Manually set font size", 1}, + { "writepng", 4, "", 0, "Instead of printing, write output to png ", 1}, + { "force-tape-width", 5, "", 0, "Set tape width in pixels, use together with --writepng without a printer connected", 1}, + { "copies", 6, "", 0, "Sets the number of identical prints", 1}, + + { 0, 0, 0, 0, "print commands:", 2}, + { "image", 'i', "", 0, "Print the given image which must be a 2 color (black/white) png", 2}, + { "text", 't', "", 0, "Print line of . If the text contains spaces, use quotation marks taround it", 2}, + { "cutmark", 'c', 0, 0, "Print a mark where the tape should be cut", 2}, + { "pad", 'p', "", 0, "Add n pixels padding (blank tape)", 2}, + { "chain", 10, 0, 0, "Skip final feed of label and any automatic cut", 2}, + { "newline", 'n', "", 0, "Add 1-4 lines for multiline text", 2}, + + { 0, 0, 0, 0, "other commands:", 3}, + { "info", 20, 0, 0, "Show info about detected tape", 3}, + { "list-supported", 21, 0, 0, "Show printers supported by this version", 3}, + { 0 } +}; + +static struct argp argp = { options, parse_opt, args_doc, doc, 0, 0, 0 }; + +struct arguments arguments = { + .chain =false, + .copies = 1, + .debug = false, + .info = false, + //.font_file = "/usr/share/fonts/TTF/Ubuntu-M.ttf", + //.font_file = "Ubuntu:medium", + .font_file = "DejaVuSans", + .font_size = 0, + .forced_tape_width = 0, + .save_png = NULL, + .verbose = 0 +}; + +job_t *jobs = NULL; +job_t *last_added_job = NULL; /* -------------------------------------------------------------------- -------------------------------------------------------------------- */ @@ -94,7 +156,7 @@ int print_img(ptouch_dev ptdev, gdImage *im, int chain) int offset = ((int)max_pixels / 2) - (gdImageSY(im)/2); /* always print centered */ printf("max_pixels=%ld, offset=%d\n", max_pixels, offset); if ((ptdev->devinfo->flags & FLAG_RASTER_PACKBITS) == FLAG_RASTER_PACKBITS) { - if (debug) { + if (arguments.debug) { printf("enable PackBits mode\n"); } ptouch_enable_packbits(ptdev); @@ -105,19 +167,19 @@ int print_img(ptouch_dev ptdev, gdImage *im, int chain) } if ((ptdev->devinfo->flags & FLAG_USE_INFO_CMD) == FLAG_USE_INFO_CMD) { ptouch_info_cmd(ptdev, gdImageSX(im)); - if (debug) { + if (arguments.debug) { printf(_("send print information command\n")); } } if ((ptdev->devinfo->flags & FLAG_D460BT_MAGIC) == FLAG_D460BT_MAGIC) { ptouch_send_d460bt_magic(ptdev); - if (debug) { + if (arguments.debug) { printf(_("send PT-D460BT magic commands\n")); } } if ((ptdev->devinfo->flags & FLAG_HAS_PRECUT) == FLAG_HAS_PRECUT) { ptouch_send_precut_cmd(ptdev, 1); - if (debug) { + if (arguments.debug) { printf(_("send precut command\n")); } } @@ -125,7 +187,7 @@ int print_img(ptouch_dev ptdev, gdImage *im, int chain) if ((ptdev->devinfo->flags & FLAG_D460BT_MAGIC) == FLAG_D460BT_MAGIC) { if (chain) { ptouch_send_d460bt_chain(ptdev); - if (debug) { + if (arguments.debug) { printf(_("send PT-D460BT chain commands\n")); } } @@ -208,7 +270,7 @@ int get_baselineoffset(char *text, char *font, int fsz) int o_offset = brect[1]; gdImageStringFT(NULL, &brect[0], -1, font, fsz, 0.0, 0, 0, text); int text_offset = brect[1]; - if (debug) { + if (arguments.debug) { printf(_("debug: o baseline offset - %d\n"), o_offset); printf(_("debug: text baseline offset - %d\n"), text_offset); } @@ -268,14 +330,14 @@ gdImage *render_text(char *font, char *line[], int lines, int print_width) char *p; gdImage *im = NULL; - if (debug) { + if (arguments.debug) { printf(_("render_text(): %i lines, font = '%s'\n"), lines, font); } if (gdFTUseFontConfig(1) != GD_TRUE) { printf(_("warning: font config not available\n")); } - if (fontsize > 0) { - fsz = fontsize; + if (arguments.font_size > 0) { + fsz = arguments.font_size; printf(_("setting font size=%i\n"), fsz); } else { for (i = 0; i < lines; ++i) { @@ -290,7 +352,7 @@ gdImage *render_text(char *font, char *line[], int lines, int print_width) printf(_("choosing font size=%i\n"), fsz); } for(i = 0; i < lines; ++i) { - tmp = needed_width(line[i], font_file, fsz); + tmp = needed_width(line[i], arguments.font_file, fsz); if (tmp > x) { x = tmp; } @@ -311,7 +373,7 @@ gdImage *render_text(char *font, char *line[], int lines, int print_width) max_height = lineheight; } } - if (debug) { + if (arguments.debug) { printf("debug: needed (max) height is %ipx\n", max_height); } if ((max_height * lines) > print_width) { @@ -322,14 +384,14 @@ gdImage *render_text(char *font, char *line[], int lines, int print_width) int unused_px = print_width - (max_height * lines); /* now render lines */ for (i = 0; i < lines; ++i) { - int ofs = get_baselineoffset(line[i], font_file, fsz); + int ofs = get_baselineoffset(line[i], arguments.font_file, fsz); //int pos = ((i)*(print_width/(lines)))+(max_height)-ofs-1; int pos = ((i)*(print_width/(lines)))+(max_height)-ofs; pos += (unused_px/lines) / 2; - if (debug) { + if (arguments.debug) { printf("debug: line %i pos=%i ofs=%i\n", i+1, pos, ofs); } - int off_x = offset_x(line[i], font_file, fsz); + int off_x = offset_x(line[i], arguments.font_file, fsz); if ((p = gdImageStringFT(im, &brect[0], -black, font, fsz, 0.0, off_x, pos, line[i])) != NULL) { printf(_("error in gdImageStringFT: %s\n"), p); } @@ -365,18 +427,18 @@ gdImage *img_append(gdImage *in_1, gdImage *in_2) } gdImageColorAllocate(out, 255, 255, 255); gdImageColorAllocate(out, 0, 0, 0); - if (debug) { + if (arguments.debug) { printf("debug: created new img with size %d * %d\n", length, width); } if (in_1 != NULL) { gdImageCopy(out, in_1, 0, 0, 0, 0, gdImageSX(in_1), gdImageSY(in_1)); - if (debug) { + if (arguments.debug) { printf("debug: copied part 1\n"); } } if (in_2 != NULL) { gdImageCopy(out, in_2, i_1_x, 0, 0, 0, gdImageSX(in_2), gdImageSY(in_2)); - if (debug) { + if (arguments.debug) { printf("copied part 2\n"); } } @@ -420,118 +482,112 @@ gdImage *img_padding(int print_width, int length) return out; } -void usage(char *progname) +void add_job(job_type_t type, int n, char *line) { - printf("usage: %s [options] \n", progname); - printf("options:\n"); - printf("\t--debug\t\t\tenable debug output\n"); - printf("\t--font \t\tuse font or \n"); - printf("\t--fontsize \tManually set fontsize\n"); - printf("\t--writepng \tinstead of printing, write output to png file\n"); - printf("\t--force-tape-width \tSet tape width in pixels, use together with\n"); - printf("\t\t\t\t--writepng without a printer connected.\n"); - printf("\t--copies \tSets the number of identical prints\n"); - printf("print commands:\n"); - printf("\t--image \t\tprint the given image which must be a 2 color\n"); - printf("\t\t\t\t(black/white) png\n"); - printf("\t--text \t\tPrint 1-4 lines of text.\n"); - printf("\t\t\t\tIf the text contains spaces, use quotation marks\n\t\t\t\taround it.\n"); - printf("\t--cutmark\t\tPrint a mark where the tape should be cut\n"); - printf("\t--pad \t\tAdd n pixels padding (blank tape)\n"); - printf("\t--chain\t\t\tSkip final feed of label and any automatic cut\n"); - printf("other commands:\n"); - printf("\t--version\t\tshow version info (required for bug report)\n"); - printf("\t--info\t\t\tshow info about detected tape\n"); - printf("\t--list-supported\tshow printers supported by this version\n"); - exit(1); + job_t *new_job = (job_t*)malloc(sizeof(job_t)); + if(!new_job) { + fprintf(stderr, "Memory allocation failed\n"); + return; + } + + new_job->type = type; + if(type == JOB_TEXT && n > MAX_LINES) { + n = MAX_LINES; + } + new_job->n = n; + new_job->lines[0] = line; + for(int i=1; ilines[i] = NULL; + new_job->next = NULL; + + if(!last_added_job) { // just created the first job + jobs = last_added_job = new_job; + return; + } + + last_added_job->next = new_job; + last_added_job = new_job; } -/* here we don't print anything, but just try to catch syntax errors */ -int parse_args(int argc, char **argv) +static error_t parse_opt(int key, char *arg, struct argp_state *state) { - int lines, i; + struct arguments *arguments = (struct arguments *)state->input; - for (i = 1; i < argc; ++i) { - if (*argv[i] != '-') { + switch (key) { + case 1: // debug + arguments->debug = true; break; - } - if (strcmp(&argv[i][1], "-font") == 0) { - if (i+1 < argc) { - font_file = argv[++i]; - } else { - usage(argv[0]); + case 2: // font + arguments->font_file = arg; + break; + case 3: // fontsize + arguments->font_size = strtol(arg, NULL, 10); + break; + case 4: // writepng + arguments->save_png = arg; + break; + case 5: // force-tape-width + arguments->forced_tape_width = strtol(arg, NULL, 10); + break; + case 6: // copies + arguments->copies = strtol(arg, NULL, 10); + break; + case 'i': // image + add_job(JOB_IMAGE, 1, arg); + break; + case 't': // text + add_job(JOB_TEXT, 1, arg); + break; + case 'c': // cutmark + add_job(JOB_CUTMARK, 0, NULL); + break; + case 'p': // pad + add_job(JOB_PAD, atoi(arg), NULL); + break; + case 10: // chain + arguments->chain = true; + break; + case 'n': // newline + if(!last_added_job || last_added_job->type != JOB_TEXT) { + add_job(JOB_TEXT, 1, arg); + break; } - } else if (strcmp(&argv[i][1], "-fontsize") == 0) { - if (i+1 < argc) { - ++i; - } else { - usage(argv[0]); + + if(last_added_job->n >= MAX_LINES) { // max number of lines reached + argp_failure(state, 1, EINVAL, _("Only up to %d lines are supported"), MAX_LINES); + break; } - } else if (strcmp(&argv[i][1], "-writepng") == 0) { - if (i+1 < argc) { - save_png = argv[++i]; - } else { - usage(argv[0]); - } - } else if (strcmp(&argv[i][1], "-force-tape-width") == 0) { - if (i+1 < argc) { - forced_tape_width = strtol(argv[++i], NULL, 10); - } else { - usage(argv[0]); - } - } else if (strcmp(&argv[i][1], "-cutmark") == 0) { - continue; /* not done here */ - } else if (strcmp(&argv[i][1], "-chain") == 0) { - chain = true; - } else if (strcmp(&argv[i][1], "-debug") == 0) { - debug = true; - } else if (strcmp(&argv[i][1], "-info") == 0) { - continue; /* not done here */ - } else if (strcmp(&argv[i][1], "-copies") == 0) { - if (i+1 < argc) { - ++i; - } else { - usage(argv[0]); - } - } else if (strcmp(&argv[i][1], "-image") == 0) { - if (i+1 < argc) { - ++i; - } else { - usage(argv[0]); - } - } else if (strcmp(&argv[i][1], "-pad") == 0) { - if (i+1 < argc) { - ++i; - } else { - usage(argv[0]); - } - } else if (strcmp(&argv[i][1], "-text") == 0) { - for (lines = 0; (lines < MAX_LINES) && (i < argc); ++lines) { - if ((i+1 >= argc) || (argv[i+1][0] == '-')) { - break; - } - ++i; - } - } else if (strcmp(&argv[i][1], "-version") == 0) { - printf(_("ptouch-print version %s by Dominic Radermacher\n"), VERSION); - exit(0); - } else if (strcmp(&argv[i][1], "-list-supported") == 0) { + + last_added_job->lines[last_added_job->n++] = arg; + break; + case 20: // info + arguments->info = true; + break; + case 21: // list-supported ptouch_list_supported(); exit(0); - } else { - usage(argv[0]); - } + case ARGP_KEY_ARG: + argp_failure(state, 1, E2BIG, _("No arguments supported")); + break; + case ARGP_KEY_END: + // final argument validation + if (arguments->forced_tape_width && !arguments->save_png) { + argp_failure(state, 1, ENOTSUP, _("Option --writepng missing")); + } + if (arguments->forced_tape_width && arguments->info) { + argp_failure(state, 1, ENOTSUP, _("Options --force_tape_width and --info can't be used together")); + } + break; + default: + return ARGP_ERR_UNKNOWN; } - if (forced_tape_width && !save_png) { - forced_tape_width = 0; - } - return i; + + return 0; } int main(int argc, char *argv[]) { - int lines = 0, copies = 1, print_width = 0; - char *line[MAX_LINES]; + int print_width = 0; gdImage *im = NULL; gdImage *out = NULL; ptouch_dev ptdev = NULL; @@ -541,13 +597,12 @@ int main(int argc, char *argv[]) if (!textdomain_dir) { textdomain_dir = "/usr/share/locale/"; } - bindtextdomain("ptouch-print", textdomain_dir); - textdomain("ptouch-print"); - int i = parse_args(argc, argv); - if (i != argc) { - usage(argv[0]); - } - if (!forced_tape_width) { + bindtextdomain(P_NAME, "/usr/share/locale/"); + textdomain(P_NAME); + + argp_parse(&argp, argc, argv, 0, 0, &arguments); + + if (!arguments.forced_tape_width) { if ((ptouch_open(&ptdev)) < 0) { return 5; } @@ -565,100 +620,84 @@ int main(int argc, char *argv[]) print_width = max_print_width; } } else { // --forced_tape_width together with --writepng - print_width = forced_tape_width; + print_width = arguments.forced_tape_width; } - for (i = 1; i < argc; ++i) { - if (*argv[i] != '-') { - break; + + if(arguments.info) { + printf(_("maximum printing width for this printer is %ldpx\n"), ptouch_get_max_width(ptdev)); + printf(_("maximum printing width for this tape is %ldpx\n"), ptouch_get_tape_width(ptdev)); + printf("media type = %02x (%s)\n", ptdev->status->media_type, pt_mediatype(ptdev->status->media_type)); + printf("media width = %d mm\n", ptdev->status->media_width); + printf("tape color = %02x (%s)\n", ptdev->status->tape_color, pt_tapecolor(ptdev->status->tape_color)); + printf("text color = %02x (%s)\n", ptdev->status->text_color, pt_textcolor(ptdev->status->text_color)); + printf("error = %04x\n", ptdev->status->error); + if (arguments.debug) { + ptouch_rawstatus((uint8_t *)ptdev->status); } - if (strcmp(&argv[i][1], "-font") == 0) { - if (i+1 < argc) { - font_file = argv[++i]; - } else { - usage(argv[0]); - } - } else if (strcmp(&argv[i][1], "-fontsize") == 0) { - if (i+1 < argc) { - fontsize = strtol(argv[++i], NULL, 10); - } else { - usage(argv[0]); - } - } else if (strcmp(&argv[i][1], "-force-tape-width") == 0) { - if (forced_tape_width && save_png) { - ++i; - continue; - } else { - usage(argv[0]); - } - } else if (strcmp(&argv[i][1], "-writepng") == 0) { - i++; - continue; - } else if (strcmp(&argv[i][1], "-info") == 0) { - printf(_("maximum printing width for this printer is %ldpx\n"), ptouch_get_max_width(ptdev)); - printf(_("maximum printing width for this tape is %ldpx\n"), ptouch_get_tape_width(ptdev)); - printf("media type = %02x (%s)\n", ptdev->status->media_type, pt_mediatype(ptdev->status->media_type)); - printf("media width = %d mm\n", ptdev->status->media_width); - printf("tape color = %02x (%s)\n", ptdev->status->tape_color, pt_tapecolor(ptdev->status->tape_color)); - printf("text color = %02x (%s)\n", ptdev->status->text_color, pt_textcolor(ptdev->status->text_color)); - printf("error = %04x\n", ptdev->status->error); - if (debug) { - ptouch_rawstatus((uint8_t *)ptdev->status); - } - exit(0); - } else if (strcmp(&argv[i][1], "-image") == 0) { - if ((im = image_load(argv[++i])) == NULL) { - printf(_("failed to load image file\n")); - return 1; - } - out = img_append(out, im); - gdImageDestroy(im); - im = NULL; - } else if (strcmp(&argv[i][1], "-text") == 0) { - for (lines = 0; (lines < MAX_LINES) && (i < argc); ++lines) { - if ((i+1 >= argc) || (argv[i+1][0] == '-')) { - break; + exit(0); + } + + // iterate through all print jobs + for(job_t *job = jobs; job != NULL; job = job->next) { + if(arguments.debug) { + printf("job %p: type=%d | n=%d", job, job->type, job->n); + for(int i=0; ilines[i]); + printf(" | next=%p\n", job->next); + } + + switch(job->type) { + case JOB_IMAGE: + if ((im = image_load(job->lines[0])) == NULL) { + printf(_("failed to load image file\n")); + return 1; } - ++i; - line[lines] = argv[i]; - } - if (lines) { - if ((im = render_text(font_file, line, lines, print_width)) == NULL) { + out = img_append(out, im); + gdImageDestroy(im); + im = NULL; + break; + case JOB_TEXT: + if ((im = render_text(arguments.font_file, job->lines, job->n, print_width)) == NULL) { printf(_("could not render text\n")); return 1; } out = img_append(out, im); gdImageDestroy(im); im = NULL; - } - } else if (strcmp(&argv[i][1], "-cutmark") == 0) { - im = img_cutmark(print_width); - out = img_append(out, im); - gdImageDestroy(im); - im = NULL; - } else if (strcmp(&argv[i][1], "-pad") == 0) { - int length=strtol(argv[++i], NULL, 10); - im = img_padding(print_width, length); - out = img_append(out, im); - gdImageDestroy(im); - im = NULL; - } else if (strcmp(&argv[i][1], "-chain") == 0) { - chain = true; - } else if (strcmp(&argv[i][1], "-debug") == 0) { - debug = true; - } else if (strcmp(&argv[i][1], "-copies") == 0) { - copies = strtol(argv[++i], NULL, 10); - } else { - usage(argv[0]); + break; + case JOB_CUTMARK: + im = img_cutmark(print_width); + out = img_append(out, im); + gdImageDestroy(im); + im = NULL; + break; + case JOB_PAD: + im = img_padding(print_width, job->n); + out = img_append(out, im); + gdImageDestroy(im); + im = NULL; + break; + default: + break; } } + + // clean up job list + for(job_t *job = jobs; job != NULL; ) { + job_t *next = job->next; + free(job); + job = next; + } + jobs = last_added_job = NULL; + if (out) { - if (save_png) { - write_png(out, save_png); + if (arguments.save_png) { + write_png(out, arguments.save_png); } else { - for (i = 0; i < copies; ++i) { - print_img(ptdev, out, chain); - if (ptouch_finalize(ptdev, ( chain || (i < copies-1) ) ) != 0) { - printf(_("ptouch_finalize(%d) failed\n"), chain); + for (int i = 0; i < arguments.copies; ++i) { + print_img(ptdev, out, arguments.chain); + if (ptouch_finalize(ptdev, ( arguments.chain || (i < arguments.copies-1) ) ) != 0) { + printf(_("ptouch_finalize(%d) failed\n"), arguments.chain); return 2; } } @@ -668,7 +707,7 @@ int main(int argc, char *argv[]) if (im != NULL) { gdImageDestroy(im); } - if (!forced_tape_width) { + if (!arguments.forced_tape_width) { ptouch_close(ptdev); } libusb_exit(NULL); From d293e9427d472866dc92ffba0392896755b3b075 Mon Sep 17 00:00:00 2001 From: Dominic Radermacher Date: Mon, 11 Aug 2025 09:57:02 +0200 Subject: [PATCH 43/53] coding style cosmetics --- src/ptouch-print.c | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/src/ptouch-print.c b/src/ptouch-print.c index 5f75451..33424a5 100644 --- a/src/ptouch-print.c +++ b/src/ptouch-print.c @@ -95,7 +95,7 @@ static struct argp_option options[] = { { "pad", 'p', "", 0, "Add n pixels padding (blank tape)", 2}, { "chain", 10, 0, 0, "Skip final feed of label and any automatic cut", 2}, { "newline", 'n', "", 0, "Add 1-4 lines for multiline text", 2}, - + { 0, 0, 0, 0, "other commands:", 3}, { "info", 20, 0, 0, "Show info about detected tape", 3}, { "list-supported", 21, 0, 0, "Show printers supported by this version", 3}, @@ -105,7 +105,7 @@ static struct argp_option options[] = { static struct argp argp = { options, parse_opt, args_doc, doc, 0, 0, 0 }; struct arguments arguments = { - .chain =false, + .chain = false, .copies = 1, .debug = false, .info = false, @@ -351,7 +351,7 @@ gdImage *render_text(char *font, char *line[], int lines, int print_width) } printf(_("choosing font size=%i\n"), fsz); } - for(i = 0; i < lines; ++i) { + for (i = 0; i < lines; ++i) { tmp = needed_width(line[i], arguments.font_file, fsz); if (tmp > x) { x = tmp; @@ -485,22 +485,22 @@ gdImage *img_padding(int print_width, int length) void add_job(job_type_t type, int n, char *line) { job_t *new_job = (job_t*)malloc(sizeof(job_t)); - if(!new_job) { - fprintf(stderr, "Memory allocation failed\n"); + if (!new_job) { + fprintf(stderr, "Memory allocation failed\n"); return; } - new_job->type = type; - if(type == JOB_TEXT && n > MAX_LINES) { + if (type == JOB_TEXT && n > MAX_LINES) { n = MAX_LINES; } new_job->n = n; new_job->lines[0] = line; - for(int i=1; ilines[i] = NULL; + } new_job->next = NULL; - if(!last_added_job) { // just created the first job + if (!last_added_job) { // just created the first job jobs = last_added_job = new_job; return; } @@ -534,10 +534,10 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) break; case 'i': // image add_job(JOB_IMAGE, 1, arg); - break; + break; case 't': // text add_job(JOB_TEXT, 1, arg); - break; + break; case 'c': // cutmark add_job(JOB_CUTMARK, 0, NULL); break; @@ -548,12 +548,12 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) arguments->chain = true; break; case 'n': // newline - if(!last_added_job || last_added_job->type != JOB_TEXT) { + if (!last_added_job || last_added_job->type != JOB_TEXT) { add_job(JOB_TEXT, 1, arg); break; } - if(last_added_job->n >= MAX_LINES) { // max number of lines reached + if (last_added_job->n >= MAX_LINES) { // max number of lines reached argp_failure(state, 1, EINVAL, _("Only up to %d lines are supported"), MAX_LINES); break; } @@ -581,7 +581,6 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) default: return ARGP_ERR_UNKNOWN; } - return 0; } @@ -623,7 +622,7 @@ int main(int argc, char *argv[]) print_width = arguments.forced_tape_width; } - if(arguments.info) { + if (arguments.info) { printf(_("maximum printing width for this printer is %ldpx\n"), ptouch_get_max_width(ptdev)); printf(_("maximum printing width for this tape is %ldpx\n"), ptouch_get_tape_width(ptdev)); printf("media type = %02x (%s)\n", ptdev->status->media_type, pt_mediatype(ptdev->status->media_type)); @@ -637,16 +636,17 @@ int main(int argc, char *argv[]) exit(0); } - // iterate through all print jobs - for(job_t *job = jobs; job != NULL; job = job->next) { - if(arguments.debug) { + // iterate through all print jobs + for (job_t *job = jobs; job != NULL; job = job->next) { + if (arguments.debug) { printf("job %p: type=%d | n=%d", job, job->type, job->n); - for(int i=0; ilines[i]); + } printf(" | next=%p\n", job->next); } - switch(job->type) { + switch (job->type) { case JOB_IMAGE: if ((im = image_load(job->lines[0])) == NULL) { printf(_("failed to load image file\n")); @@ -683,7 +683,7 @@ int main(int argc, char *argv[]) } // clean up job list - for(job_t *job = jobs; job != NULL; ) { + for (job_t *job = jobs; job != NULL; ) { job_t *next = job->next; free(job); job = next; From e730c3b480e5959e655f7622462f77ff39e5b6fc Mon Sep 17 00:00:00 2001 From: Dominic Radermacher Date: Mon, 11 Aug 2025 15:09:36 +0200 Subject: [PATCH 44/53] better help text for newline arg, rename build script --- README | 2 +- build.sh => compile.sh | 0 po/de.po | 10 +++++----- po/en.po | 10 +++++----- po/ptouch.pot | 10 +++++----- src/ptouch-print.c | 2 +- 6 files changed, 17 insertions(+), 17 deletions(-) rename build.sh => compile.sh (100%) diff --git a/README b/README index b3e6a6b..7e2e0f3 100644 --- a/README +++ b/README @@ -16,7 +16,7 @@ https://dominic.familie-radermacher.ch/projekte/ptouch-print/ Compile instructions: -./build.sh +./compile.sh Note: diff --git a/build.sh b/compile.sh similarity index 100% rename from build.sh rename to compile.sh diff --git a/po/de.po b/po/de.po index e54c3f4..ca344fd 100644 --- a/po/de.po +++ b/po/de.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: ptouch-print 1.3.1\n" "Report-Msgid-Bugs-To: dominic@familie-radermacher.ch\n" -"POT-Creation-Date: 2025-08-11 09:46+0200\n" +"POT-Creation-Date: 2025-08-11 09:57+0200\n" "PO-Revision-Date: 2024-05-23 22:27-0400\n" "Last-Translator: dominic@familie-radermacher.ch\n" "Language-Team: German \n" @@ -267,22 +267,22 @@ msgstr "" msgid "Options --force_tape_width and --info can't be used together" msgstr "" -#: src/ptouch-print.c:610 +#: src/ptouch-print.c:609 #, c-format msgid "ptouch_init() failed\n" msgstr "ptouch_init() fehlgeschlagen\n" -#: src/ptouch-print.c:613 +#: src/ptouch-print.c:612 #, c-format msgid "ptouch_getstatus() failed\n" msgstr "ptouch_getstatus() fehlgeschlagen\n" -#: src/ptouch-print.c:627 +#: src/ptouch-print.c:626 #, fuzzy, c-format msgid "maximum printing width for this printer is %ldpx\n" msgstr "Maximal druckbare Breite für dieses Schriftband sind %ipx\n" -#: src/ptouch-print.c:628 +#: src/ptouch-print.c:627 #, fuzzy, c-format msgid "maximum printing width for this tape is %ldpx\n" msgstr "Maximal druckbare Breite für dieses Schriftband sind %ipx\n" diff --git a/po/en.po b/po/en.po index c6eb2d8..bb3c2c1 100644 --- a/po/en.po +++ b/po/en.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: ptouch-print 1.3.1\n" "Report-Msgid-Bugs-To: dominic@familie-radermacher.ch\n" -"POT-Creation-Date: 2025-08-11 09:46+0200\n" +"POT-Creation-Date: 2025-08-11 09:57+0200\n" "PO-Revision-Date: 2024-05-23 22:26-0400\n" "Last-Translator: dominic@familie-radermacher.ch\n" "Language-Team: English \n" @@ -267,22 +267,22 @@ msgstr "" msgid "Options --force_tape_width and --info can't be used together" msgstr "" -#: src/ptouch-print.c:610 +#: src/ptouch-print.c:609 #, c-format msgid "ptouch_init() failed\n" msgstr "ptouch_init() failed\n" -#: src/ptouch-print.c:613 +#: src/ptouch-print.c:612 #, c-format msgid "ptouch_getstatus() failed\n" msgstr "ptouch_getstatus() failed\n" -#: src/ptouch-print.c:627 +#: src/ptouch-print.c:626 #, fuzzy, c-format msgid "maximum printing width for this printer is %ldpx\n" msgstr "maximum printing width for this tape is %ipx\n" -#: src/ptouch-print.c:628 +#: src/ptouch-print.c:627 #, fuzzy, c-format msgid "maximum printing width for this tape is %ldpx\n" msgstr "maximum printing width for this tape is %ipx\n" diff --git a/po/ptouch.pot b/po/ptouch.pot index d7ac264..92904d9 100644 --- a/po/ptouch.pot +++ b/po/ptouch.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: ptouch-print\n" "Report-Msgid-Bugs-To: dominic@familie-radermacher.ch\n" -"POT-Creation-Date: 2025-08-11 09:46+0200\n" +"POT-Creation-Date: 2025-08-11 10:05+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -265,22 +265,22 @@ msgstr "" msgid "Options --force_tape_width and --info can't be used together" msgstr "" -#: src/ptouch-print.c:610 +#: src/ptouch-print.c:609 #, c-format msgid "ptouch_init() failed\n" msgstr "" -#: src/ptouch-print.c:613 +#: src/ptouch-print.c:612 #, c-format msgid "ptouch_getstatus() failed\n" msgstr "" -#: src/ptouch-print.c:627 +#: src/ptouch-print.c:626 #, c-format msgid "maximum printing width for this printer is %ldpx\n" msgstr "" -#: src/ptouch-print.c:628 +#: src/ptouch-print.c:627 #, c-format msgid "maximum printing width for this tape is %ldpx\n" msgstr "" diff --git a/src/ptouch-print.c b/src/ptouch-print.c index 33424a5..eb64564 100644 --- a/src/ptouch-print.c +++ b/src/ptouch-print.c @@ -94,7 +94,7 @@ static struct argp_option options[] = { { "cutmark", 'c', 0, 0, "Print a mark where the tape should be cut", 2}, { "pad", 'p', "", 0, "Add n pixels padding (blank tape)", 2}, { "chain", 10, 0, 0, "Skip final feed of label and any automatic cut", 2}, - { "newline", 'n', "", 0, "Add 1-4 lines for multiline text", 2}, + { "newline", 'n', "", 0, "Add text in a new line (up to 4 lines)", 2}, { 0, 0, 0, 0, "other commands:", 3}, { "info", 20, 0, 0, "Show info about detected tape", 3}, From d8a4ed71e27591b95d6302664e9ac73f9d9c01aa Mon Sep 17 00:00:00 2001 From: Markus Schramma Date: Sun, 28 Sep 2025 08:05:41 +0200 Subject: [PATCH 45/53] add --timeout option --- include/ptouch.h | 2 +- po/de.po | 64 ++++++++++++++++++++++---------------------- po/en.po | 66 +++++++++++++++++++++++----------------------- po/ptouch.pot | 64 ++++++++++++++++++++++---------------------- ptouch-print.1 | 6 +++++ src/libptouch.c | 8 +++--- src/ptouch-print.c | 10 +++++-- 7 files changed, 116 insertions(+), 104 deletions(-) diff --git a/include/ptouch.h b/include/ptouch.h index 76d64e5..1fc1d0c 100644 --- a/include/ptouch.h +++ b/include/ptouch.h @@ -106,7 +106,7 @@ size_t ptouch_get_max_width(ptouch_dev ptdev); size_t ptouch_get_tape_width(ptouch_dev ptdev); int ptouch_page_flags(ptouch_dev ptdev, uint8_t page_flags); int ptouch_finalize(ptouch_dev ptdev, int chain); -int ptouch_getstatus(ptouch_dev ptdev); +int ptouch_getstatus(ptouch_dev ptdev, int timeout); int ptouch_getmaxwidth(ptouch_dev ptdev); int ptouch_send_d460bt_magic(ptouch_dev ptdev); int ptouch_send_d460bt_chain(ptouch_dev ptdev); diff --git a/po/de.po b/po/de.po index ca344fd..19cf85d 100644 --- a/po/de.po +++ b/po/de.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: ptouch-print 1.3.1\n" "Report-Msgid-Bugs-To: dominic@familie-radermacher.ch\n" -"POT-Creation-Date: 2025-08-11 09:57+0200\n" +"POT-Creation-Date: 2025-09-28 08:03+0200\n" "PO-Revision-Date: 2024-05-23 22:27-0400\n" "Last-Translator: dominic@familie-radermacher.ch\n" "Language-Team: German \n" @@ -107,7 +107,7 @@ msgstr "" #: src/libptouch.c:371 #, c-format -msgid "timeout while waiting for status response\n" +msgid "timeout (%i sec) while waiting for status response\n" msgstr "" #: src/libptouch.c:385 @@ -155,149 +155,149 @@ msgstr "" msgid "debug: called ptouch_sendraster() with NULL ptdev\n" msgstr "" -#: src/ptouch-print.c:143 +#: src/ptouch-print.c:146 #, c-format msgid "nothing to print\n" msgstr "" -#: src/ptouch-print.c:151 +#: src/ptouch-print.c:154 #, c-format msgid "image is too large (%ipx x %ipx)\n" msgstr "Bild ist zu gross (%ipx x %ipx)\n" -#: src/ptouch-print.c:152 +#: src/ptouch-print.c:155 #, c-format msgid "maximum printing width for this tape is %ipx\n" msgstr "Maximal druckbare Breite für dieses Schriftband sind %ipx\n" -#: src/ptouch-print.c:155 +#: src/ptouch-print.c:158 #, fuzzy, c-format msgid "image size (%ipx x %ipx)\n" msgstr "Bild ist zu gross (%ipx x %ipx)\n" -#: src/ptouch-print.c:165 +#: src/ptouch-print.c:168 #, c-format msgid "ptouch_rasterstart() failed\n" msgstr "ptouch_rasterstart() fehlgeschlagen\n" -#: src/ptouch-print.c:171 +#: src/ptouch-print.c:174 #, c-format msgid "send print information command\n" msgstr "" -#: src/ptouch-print.c:177 +#: src/ptouch-print.c:180 #, c-format msgid "send PT-D460BT magic commands\n" msgstr "" -#: src/ptouch-print.c:183 +#: src/ptouch-print.c:186 #, c-format msgid "send precut command\n" msgstr "" -#: src/ptouch-print.c:191 +#: src/ptouch-print.c:194 #, c-format msgid "send PT-D460BT chain commands\n" msgstr "" -#: src/ptouch-print.c:203 +#: src/ptouch-print.c:206 #, fuzzy, c-format msgid "ptouch_sendraster() failed\n" msgstr "ptouch_send() fehlgeschlagen\n" -#: src/ptouch-print.c:252 +#: src/ptouch-print.c:255 #, c-format msgid "writing image '%s' failed\n" msgstr "Schreiben der Bilddatei '%s' fehlgeschlagen\n" -#: src/ptouch-print.c:274 +#: src/ptouch-print.c:277 #, c-format msgid "debug: o baseline offset - %d\n" msgstr "" -#: src/ptouch-print.c:275 +#: src/ptouch-print.c:278 #, c-format msgid "debug: text baseline offset - %d\n" msgstr "" -#: src/ptouch-print.c:334 +#: src/ptouch-print.c:337 #, c-format msgid "render_text(): %i lines, font = '%s'\n" msgstr "" -#: src/ptouch-print.c:337 +#: src/ptouch-print.c:340 #, c-format msgid "warning: font config not available\n" msgstr "Warnung: fontconfig ist nicht verfügbar\n" -#: src/ptouch-print.c:341 +#: src/ptouch-print.c:344 #, c-format msgid "setting font size=%i\n" msgstr "setze Zeichensatzgrösse=%i\n" -#: src/ptouch-print.c:345 +#: src/ptouch-print.c:348 #, c-format msgid "could not estimate needed font size\n" msgstr "Konnte die notwendige Zeichensatzgrösse nicht bestimmen\n" -#: src/ptouch-print.c:352 +#: src/ptouch-print.c:355 #, c-format msgid "choosing font size=%i\n" msgstr "Wähle Zeichensatzgrösse %i\n" -#: src/ptouch-print.c:368 src/ptouch-print.c:396 +#: src/ptouch-print.c:371 src/ptouch-print.c:399 #, c-format msgid "error in gdImageStringFT: %s\n" msgstr "Fehler in Funktion gdImageStringFT(): %s\n" -#: src/ptouch-print.c:557 +#: src/ptouch-print.c:563 #, c-format msgid "Only up to %d lines are supported" msgstr "" -#: src/ptouch-print.c:570 +#: src/ptouch-print.c:576 msgid "No arguments supported" msgstr "" -#: src/ptouch-print.c:575 +#: src/ptouch-print.c:581 msgid "Option --writepng missing" msgstr "" -#: src/ptouch-print.c:578 +#: src/ptouch-print.c:584 msgid "Options --force_tape_width and --info can't be used together" msgstr "" -#: src/ptouch-print.c:609 +#: src/ptouch-print.c:615 #, c-format msgid "ptouch_init() failed\n" msgstr "ptouch_init() fehlgeschlagen\n" -#: src/ptouch-print.c:612 +#: src/ptouch-print.c:618 #, c-format msgid "ptouch_getstatus() failed\n" msgstr "ptouch_getstatus() fehlgeschlagen\n" -#: src/ptouch-print.c:626 +#: src/ptouch-print.c:632 #, fuzzy, c-format msgid "maximum printing width for this printer is %ldpx\n" msgstr "Maximal druckbare Breite für dieses Schriftband sind %ipx\n" -#: src/ptouch-print.c:627 +#: src/ptouch-print.c:633 #, fuzzy, c-format msgid "maximum printing width for this tape is %ldpx\n" msgstr "Maximal druckbare Breite für dieses Schriftband sind %ipx\n" -#: src/ptouch-print.c:652 +#: src/ptouch-print.c:658 #, c-format msgid "failed to load image file\n" msgstr "" -#: src/ptouch-print.c:661 +#: src/ptouch-print.c:667 #, c-format msgid "could not render text\n" msgstr "Konnte Text nicht rendern\n" -#: src/ptouch-print.c:700 +#: src/ptouch-print.c:706 #, c-format msgid "ptouch_finalize(%d) failed\n" msgstr "ptouch_finalize(%d) fehlgeschlagen\n" diff --git a/po/en.po b/po/en.po index bb3c2c1..82b2483 100644 --- a/po/en.po +++ b/po/en.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: ptouch-print 1.3.1\n" "Report-Msgid-Bugs-To: dominic@familie-radermacher.ch\n" -"POT-Creation-Date: 2025-08-11 09:57+0200\n" +"POT-Creation-Date: 2025-09-28 08:03+0200\n" "PO-Revision-Date: 2024-05-23 22:26-0400\n" "Last-Translator: dominic@familie-radermacher.ch\n" "Language-Team: English \n" @@ -106,8 +106,8 @@ msgid "read error: %s\n" msgstr "read error: %s\n" #: src/libptouch.c:371 -#, c-format -msgid "timeout while waiting for status response\n" +#, fuzzy, c-format +msgid "timeout (%i sec) while waiting for status response\n" msgstr "timeout while waiting for status response\n" #: src/libptouch.c:385 @@ -155,149 +155,149 @@ msgstr "" msgid "debug: called ptouch_sendraster() with NULL ptdev\n" msgstr "" -#: src/ptouch-print.c:143 +#: src/ptouch-print.c:146 #, c-format msgid "nothing to print\n" msgstr "" -#: src/ptouch-print.c:151 +#: src/ptouch-print.c:154 #, c-format msgid "image is too large (%ipx x %ipx)\n" msgstr "image is too large (%ipx x %ipx)\n" -#: src/ptouch-print.c:152 +#: src/ptouch-print.c:155 #, c-format msgid "maximum printing width for this tape is %ipx\n" msgstr "maximum printing width for this tape is %ipx\n" -#: src/ptouch-print.c:155 +#: src/ptouch-print.c:158 #, fuzzy, c-format msgid "image size (%ipx x %ipx)\n" msgstr "image is too large (%ipx x %ipx)\n" -#: src/ptouch-print.c:165 +#: src/ptouch-print.c:168 #, c-format msgid "ptouch_rasterstart() failed\n" msgstr "ptouch_rasterstart() failed\n" -#: src/ptouch-print.c:171 +#: src/ptouch-print.c:174 #, c-format msgid "send print information command\n" msgstr "" -#: src/ptouch-print.c:177 +#: src/ptouch-print.c:180 #, c-format msgid "send PT-D460BT magic commands\n" msgstr "" -#: src/ptouch-print.c:183 +#: src/ptouch-print.c:186 #, c-format msgid "send precut command\n" msgstr "" -#: src/ptouch-print.c:191 +#: src/ptouch-print.c:194 #, c-format msgid "send PT-D460BT chain commands\n" msgstr "" -#: src/ptouch-print.c:203 +#: src/ptouch-print.c:206 #, c-format msgid "ptouch_sendraster() failed\n" msgstr "ptouch_sendraster() failed\n" -#: src/ptouch-print.c:252 +#: src/ptouch-print.c:255 #, c-format msgid "writing image '%s' failed\n" msgstr "writing image '%s' failed\n" -#: src/ptouch-print.c:274 +#: src/ptouch-print.c:277 #, c-format msgid "debug: o baseline offset - %d\n" msgstr "" -#: src/ptouch-print.c:275 +#: src/ptouch-print.c:278 #, c-format msgid "debug: text baseline offset - %d\n" msgstr "" -#: src/ptouch-print.c:334 +#: src/ptouch-print.c:337 #, c-format msgid "render_text(): %i lines, font = '%s'\n" msgstr "" -#: src/ptouch-print.c:337 +#: src/ptouch-print.c:340 #, c-format msgid "warning: font config not available\n" msgstr "warning: font config not available\n" -#: src/ptouch-print.c:341 +#: src/ptouch-print.c:344 #, c-format msgid "setting font size=%i\n" msgstr "setting font size=%i\n" -#: src/ptouch-print.c:345 +#: src/ptouch-print.c:348 #, c-format msgid "could not estimate needed font size\n" msgstr "could not estimate needed font size\n" -#: src/ptouch-print.c:352 +#: src/ptouch-print.c:355 #, c-format msgid "choosing font size=%i\n" msgstr "choosing font size=%i\n" -#: src/ptouch-print.c:368 src/ptouch-print.c:396 +#: src/ptouch-print.c:371 src/ptouch-print.c:399 #, c-format msgid "error in gdImageStringFT: %s\n" msgstr "error in gdImageStringFT: %s\n" -#: src/ptouch-print.c:557 +#: src/ptouch-print.c:563 #, c-format msgid "Only up to %d lines are supported" msgstr "" -#: src/ptouch-print.c:570 +#: src/ptouch-print.c:576 msgid "No arguments supported" msgstr "" -#: src/ptouch-print.c:575 +#: src/ptouch-print.c:581 msgid "Option --writepng missing" msgstr "" -#: src/ptouch-print.c:578 +#: src/ptouch-print.c:584 msgid "Options --force_tape_width and --info can't be used together" msgstr "" -#: src/ptouch-print.c:609 +#: src/ptouch-print.c:615 #, c-format msgid "ptouch_init() failed\n" msgstr "ptouch_init() failed\n" -#: src/ptouch-print.c:612 +#: src/ptouch-print.c:618 #, c-format msgid "ptouch_getstatus() failed\n" msgstr "ptouch_getstatus() failed\n" -#: src/ptouch-print.c:626 +#: src/ptouch-print.c:632 #, fuzzy, c-format msgid "maximum printing width for this printer is %ldpx\n" msgstr "maximum printing width for this tape is %ipx\n" -#: src/ptouch-print.c:627 +#: src/ptouch-print.c:633 #, fuzzy, c-format msgid "maximum printing width for this tape is %ldpx\n" msgstr "maximum printing width for this tape is %ipx\n" -#: src/ptouch-print.c:652 +#: src/ptouch-print.c:658 #, c-format msgid "failed to load image file\n" msgstr "" -#: src/ptouch-print.c:661 +#: src/ptouch-print.c:667 #, c-format msgid "could not render text\n" msgstr "could not render text\n" -#: src/ptouch-print.c:700 +#: src/ptouch-print.c:706 #, c-format msgid "ptouch_finalize(%d) failed\n" msgstr "ptouch_finalize(%d) failed\n" diff --git a/po/ptouch.pot b/po/ptouch.pot index 92904d9..b3f5988 100644 --- a/po/ptouch.pot +++ b/po/ptouch.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: ptouch-print\n" "Report-Msgid-Bugs-To: dominic@familie-radermacher.ch\n" -"POT-Creation-Date: 2025-08-11 10:05+0200\n" +"POT-Creation-Date: 2025-09-28 08:03+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -105,7 +105,7 @@ msgstr "" #: src/libptouch.c:371 #, c-format -msgid "timeout while waiting for status response\n" +msgid "timeout (%i sec) while waiting for status response\n" msgstr "" #: src/libptouch.c:385 @@ -153,149 +153,149 @@ msgstr "" msgid "debug: called ptouch_sendraster() with NULL ptdev\n" msgstr "" -#: src/ptouch-print.c:143 +#: src/ptouch-print.c:146 #, c-format msgid "nothing to print\n" msgstr "" -#: src/ptouch-print.c:151 +#: src/ptouch-print.c:154 #, c-format msgid "image is too large (%ipx x %ipx)\n" msgstr "" -#: src/ptouch-print.c:152 +#: src/ptouch-print.c:155 #, c-format msgid "maximum printing width for this tape is %ipx\n" msgstr "" -#: src/ptouch-print.c:155 +#: src/ptouch-print.c:158 #, c-format msgid "image size (%ipx x %ipx)\n" msgstr "" -#: src/ptouch-print.c:165 +#: src/ptouch-print.c:168 #, c-format msgid "ptouch_rasterstart() failed\n" msgstr "" -#: src/ptouch-print.c:171 +#: src/ptouch-print.c:174 #, c-format msgid "send print information command\n" msgstr "" -#: src/ptouch-print.c:177 +#: src/ptouch-print.c:180 #, c-format msgid "send PT-D460BT magic commands\n" msgstr "" -#: src/ptouch-print.c:183 +#: src/ptouch-print.c:186 #, c-format msgid "send precut command\n" msgstr "" -#: src/ptouch-print.c:191 +#: src/ptouch-print.c:194 #, c-format msgid "send PT-D460BT chain commands\n" msgstr "" -#: src/ptouch-print.c:203 +#: src/ptouch-print.c:206 #, c-format msgid "ptouch_sendraster() failed\n" msgstr "" -#: src/ptouch-print.c:252 +#: src/ptouch-print.c:255 #, c-format msgid "writing image '%s' failed\n" msgstr "" -#: src/ptouch-print.c:274 +#: src/ptouch-print.c:277 #, c-format msgid "debug: o baseline offset - %d\n" msgstr "" -#: src/ptouch-print.c:275 +#: src/ptouch-print.c:278 #, c-format msgid "debug: text baseline offset - %d\n" msgstr "" -#: src/ptouch-print.c:334 +#: src/ptouch-print.c:337 #, c-format msgid "render_text(): %i lines, font = '%s'\n" msgstr "" -#: src/ptouch-print.c:337 +#: src/ptouch-print.c:340 #, c-format msgid "warning: font config not available\n" msgstr "" -#: src/ptouch-print.c:341 +#: src/ptouch-print.c:344 #, c-format msgid "setting font size=%i\n" msgstr "" -#: src/ptouch-print.c:345 +#: src/ptouch-print.c:348 #, c-format msgid "could not estimate needed font size\n" msgstr "" -#: src/ptouch-print.c:352 +#: src/ptouch-print.c:355 #, c-format msgid "choosing font size=%i\n" msgstr "" -#: src/ptouch-print.c:368 src/ptouch-print.c:396 +#: src/ptouch-print.c:371 src/ptouch-print.c:399 #, c-format msgid "error in gdImageStringFT: %s\n" msgstr "" -#: src/ptouch-print.c:557 +#: src/ptouch-print.c:563 #, c-format msgid "Only up to %d lines are supported" msgstr "" -#: src/ptouch-print.c:570 +#: src/ptouch-print.c:576 msgid "No arguments supported" msgstr "" -#: src/ptouch-print.c:575 +#: src/ptouch-print.c:581 msgid "Option --writepng missing" msgstr "" -#: src/ptouch-print.c:578 +#: src/ptouch-print.c:584 msgid "Options --force_tape_width and --info can't be used together" msgstr "" -#: src/ptouch-print.c:609 +#: src/ptouch-print.c:615 #, c-format msgid "ptouch_init() failed\n" msgstr "" -#: src/ptouch-print.c:612 +#: src/ptouch-print.c:618 #, c-format msgid "ptouch_getstatus() failed\n" msgstr "" -#: src/ptouch-print.c:626 +#: src/ptouch-print.c:632 #, c-format msgid "maximum printing width for this printer is %ldpx\n" msgstr "" -#: src/ptouch-print.c:627 +#: src/ptouch-print.c:633 #, c-format msgid "maximum printing width for this tape is %ldpx\n" msgstr "" -#: src/ptouch-print.c:652 +#: src/ptouch-print.c:658 #, c-format msgid "failed to load image file\n" msgstr "" -#: src/ptouch-print.c:661 +#: src/ptouch-print.c:667 #, c-format msgid "could not render text\n" msgstr "" -#: src/ptouch-print.c:700 +#: src/ptouch-print.c:706 #, c-format msgid "ptouch_finalize(%d) failed\n" msgstr "" diff --git a/ptouch-print.1 b/ptouch-print.1 index 05ddc49..6af269c 100644 --- a/ptouch-print.1 +++ b/ptouch-print.1 @@ -28,6 +28,12 @@ once in any order, and will be executed in the given order. .TP .BR \-\-debug Enables printing of debugging information. +.TP +.BR \-\-timeout\ \fI