1
0
mirror of https://git.familie-radermacher.ch/linux/ptouch-print.git synced 2025-05-13 23:32:59 +00:00

Compare commits

..

30 Commits
v1.5 ... master

Author SHA1 Message Date
Dominic Radermacher
140bf0a6cc for printers with less than 128px printhead, make sure we dont print too much pixels 2025-05-12 18:29:56 +02:00
Dominic Radermacher
a6c67df2c9 cosmetics 2025-05-12 17:59:45 +02:00
Dominic Radermacher
ec923ed579 Add support for PT-2300 and fix 112px width centering (thanks to Bradley Erickson) 2025-05-12 17:47:00 +02:00
Nico Sonack
aa5392bc13 zero-initialise array to silence valgrind 2024-10-29 20:21:48 +01:00
Dominic Radermacher
740b20e150 Add --copies switch for multiple printouts (thanks to Wojciech Fred) 2024-10-06 17:46:29 +02:00
Jan Baier
bc7d32a6e6 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.
2024-08-15 09:44:19 +02:00
Didi Kohen
9cae7f465b improve udev rules 2024-08-11 13:53:05 +02:00
Dominic Radermacher
9a0ef8c7d6 Fix chain print support for the D460BT family (thanks to Guilherme Espada) 2024-08-11 13:31:20 +02:00
Dominic Radermacher
b904e22cf1 Add --force-tape-with, enables use of --writepng without the need of a printer connected (thanks to Didi Kohen) 2024-08-11 13:15:22 +02:00
Kevin Thibedeau
da9ed2600a Add chain mode and set precut flag for PT-2700 2024-06-10 16:54:07 +02:00
Dominic Radermacher
a51fcf98f8 add and install udev rules to enable non-root access (thanks to Patrick Huesmann for contribution) 2024-04-18 09:29:38 +02:00
Ed Maste
8aaeecd84b Add different libusb include path for FreeBSD 2024-02-11 10:34:28 +01:00
Ed Maste
ad4e1541de Add cast to silence a compiler warning 2024-02-11 10:33:29 +01:00
Ed Maste
dc5b974e74 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.
2024-02-11 10:31:02 +01:00
Nedko Boshkilov
312adc3209 fix baseline for cyrillic font 2024-02-11 10:29:01 +01:00
Martin Dvořák
935dd9a31b added PT-D410 2024-01-05 16:18:31 +01:00
Florian J. Breunig
06a8001bf4 added PT-D610BT
Signed-off-by: Florian J. Breunig <Florian.J.Breunig@my-flow.com>
2024-01-05 07:56:33 +01:00
Dominic Radermacher
5fbd590f01 fix missing pixels on right side - thanks to patch from Boris-Chengbiao 2023-11-28 10:23:54 +01:00
Dominic Radermacher
f22e844eed add (untested) support for PT-D460BT thanks to ccfreak2k 2023-10-13 12:30:33 +02:00
Dominic Radermacher
8b631a7996 hopefully fix libitnl linking issues 2023-05-22 10:05:55 +02:00
Dominic Radermacher
01d661493f update manpage and project url 2023-03-13 11:17:03 +01:00
Dominic Radermacher
6b82cd6166 small cosmetic change to CMakeLists.txt 2022-11-24 06:45:01 +01:00
Dominic Radermacher
53987c4150 cosmetic changes (some are overdue since many years) 2022-10-05 18:08:06 +02:00
Dominic Radermacher
f56d7ea740 fix some compile warnings 2022-09-11 06:45:00 +02:00
Dominic Radermacher
71396e8ff1 change init to first invalidate, then init (maybe needed for some ptouch models?) 2022-09-11 06:29:44 +02:00
Dominic Radermacher
ffc1b1f7b1 media type info now also with text output, thanks to Sönke Peters 2022-09-11 06:25:35 +02:00
Dominic Radermacher
674e0da5fb add debug output 2022-04-05 20:25:54 +02:00
Dominic Radermacher
e968176637 fix text centering 2021-10-11 19:31:15 +02:00
Dominic Radermacher
f74d068776 add install target 2021-10-11 11:50:54 +02:00
Dominic Radermacher
a2d2548867 fix generation of version.h 2021-10-11 10:36:58 +02:00
11 changed files with 733 additions and 360 deletions

View File

@ -1,31 +1,58 @@
cmake_minimum_required(VERSION 3.15) cmake_minimum_required(VERSION 3.15)
project(ptouch-print C) project(ptouch-print C)
# Configure CMake
set(CMAKE_C_STANDARD 11)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake") 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 # Configure required dependencies
find_package(Gettext REQUIRED) find_package(Gettext REQUIRED)
find_package(GD REQUIRED) find_package(GD REQUIRED)
find_package(Git REQUIRED)
find_package(PkgConfig REQUIRED) find_package(PkgConfig REQUIRED)
find_package(Intl REQUIRED) find_package(Intl REQUIRED)
pkg_check_modules(LIBUSB REQUIRED libusb-1.0) pkg_check_modules(LIBUSB REQUIRED libusb-1.0)
# Configure project executable # Configure project executable
add_executable(ptouch-print) add_executable(${PROJECT_NAME})
target_sources(ptouch-print PUBLIC target_include_directories(${PROJECT_NAME} PUBLIC
version.h ${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_LIBRARIES}
)
target_sources(${PROJECT_NAME} PRIVATE
include/ptouch.h include/ptouch.h
include/gettext.h include/gettext.h
src/libptouch.c src/libptouch.c
src/ptouch-print.c src/ptouch-print.c
) )
# Configure compiler add_dependencies(${PROJECT_NAME}
target_compile_options(ptouch-print PUBLIC 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 -g
-Wall -Wall
-Wextra -Wextra
@ -34,32 +61,16 @@ target_compile_options(ptouch-print PUBLIC
-fPIC -fPIC
) )
target_compile_definitions(ptouch-print PUBLIC # HB9HEI - custom target that produces version.h (req. cmake 3.0)
LOCALEDIR="${CMAKE_INSTALL_LOCALEDIR}" add_custom_target(git-version ALL
USING_CMAKE=1 ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/gitversion.cmake
PACKAGE="ptouch-print"
) )
target_include_directories(ptouch-print PUBLIC install(TARGETS ${PROJECT_NAME} DESTINATION bin)
include
${GD_INCLUDE_DIR}
${LIBUSB_INCLUDE_DIRS}
${CMAKE_BINARY_DIR}
${Libintl_INCLUDE_DIRS}
)
# Configure linker install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/ptouch-print.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1)
target_link_libraries(ptouch-print
${GD_LIBRARIES}
${LIBUSB_LIBRARIES}
${Libintl_LIBRARY}
)
# Add a custom command that produces version.h, plus a dummy output that's if(EXISTS /etc/udev/rules.d)
# not produced, in order to force gitversion.cmake to always be re-run install(FILES udev/90-usb-ptouch-permissions.rules DESTINATION /etc/udev/rules.d)
# before the build install(CODE "execute_process(COMMAND udevadm control --reload-rules)")
ADD_CUSTOM_COMMAND( endif()
OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/version.h
${CMAKE_BINARY_DIR}/_version.h
COMMAND ${CMAKE_COMMAND} -P
${CMAKE_CURRENT_SOURCE_DIR}/cmake/gitversion.cmake)

2
README
View File

@ -12,7 +12,7 @@ Maybe others work too (please report USB VID and PID so I can include support
for further models, too). for further models, too).
Further info can be found at: Further info can be found at:
https://familie-radermacher.ch/dominic/projekte/ptouch-print/ https://dominic.familie-radermacher.ch/projekte/ptouch-print/
Compile instructions: Compile instructions:

View File

@ -1,3 +1,6 @@
# HB9HEI - required for autogen version.h
find_package(Git REQUIRED)
# Get commit hash # Get commit hash
execute_process(COMMAND git log --format='%H' -n 1 execute_process(COMMAND git log --format='%H' -n 1
OUTPUT_VARIABLE GIT_COMMIT_HASH OUTPUT_VARIABLE GIT_COMMIT_HASH
@ -30,13 +33,16 @@ else()
string(STRIP "${GIT_COMMITS}" GIT_COMMITS) string(STRIP "${GIT_COMMITS}" GIT_COMMITS)
string(STRIP "${GIT_DIFF}" GIT_DIFF) string(STRIP "${GIT_DIFF}" GIT_DIFF)
string(STRIP "${GIT_TAG}" GIT_TAG) string(STRIP "${GIT_TAG}" GIT_TAG)
if (${GIT_COMMITS} STREQUAL ${GIT_TAG})
set(GIT_COMMITS "0")
endif()
endif() endif()
set(VERSION "const char* GIT_BRANCH=\"${GIT_BRANCH}\"; set(VERSION "#define GIT_BRANCH \"${GIT_BRANCH}\"
const char* GIT_COMMIT=\"${GIT_COMMIT_SHORT}\"; #define GIT_COMMIT \"${GIT_COMMIT_SHORT}\"
const char* GIT_COMMITS=\"${GIT_COMMITS}\"; #define GIT_COMMITS \"${GIT_COMMITS}\"
const char* GIT_TAG=\"${GIT_TAG}\"; #define GIT_TAG \"${GIT_TAG}\"
const char* VERSION=\"${GIT_TAG}-r${GIT_COMMITS}-g${GIT_COMMIT_SHORT}${GIT_DIFF}\"; #define VERSION \"${GIT_TAG}.r${GIT_COMMITS}.g${GIT_COMMIT_SHORT}${GIT_DIFF}\"
") ")
message(DEBUG "Generated Version: \"${VERSION}\"") message(DEBUG "Generated Version: \"${VERSION}\"")

View File

@ -1,7 +1,7 @@
/* /*
ptouch-print - Print labels with images or text on a Brother P-Touch ptouch-print - Print labels with images or text on a Brother P-Touch
Copyright (C) 2015-2021 Dominic Radermacher <dominic@familie-radermacher.ch> Copyright (C) 2015-2023 Dominic Radermacher <dominic@familie-radermacher.ch>
This program is free software; you can redistribute it and/or modify it 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 under the terms of the GNU General Public License version 3 as
@ -18,7 +18,11 @@
*/ */
#include <stdint.h> #include <stdint.h>
#ifdef __FreeBSD__
#include <libusb.h>
#else
#include <libusb-1.0/libusb.h> #include <libusb-1.0/libusb.h>
#endif
struct _pt_tape_info { struct _pt_tape_info {
uint8_t mm; /* Tape width in mm */ uint8_t mm; /* Tape width in mm */
@ -32,6 +36,8 @@ struct _pt_tape_info {
#define FLAG_PLITE (1 << 2) #define FLAG_PLITE (1 << 2)
#define FLAG_P700_INIT (1 << 3) #define FLAG_P700_INIT (1 << 3)
#define FLAG_USE_INFO_CMD (1 << 4) #define FLAG_USE_INFO_CMD (1 << 4)
#define FLAG_HAS_PRECUT (1 << 5)
#define FLAG_D460BT_MAGIC (1 << 6)
typedef enum _pt_page_flags { typedef enum _pt_page_flags {
FEED_NONE = 0x0, FEED_NONE = 0x0,
@ -96,14 +102,22 @@ int ptouch_send(ptouch_dev ptdev, uint8_t *data, size_t len);
int ptouch_init(ptouch_dev ptdev); int ptouch_init(ptouch_dev ptdev);
int ptouch_lf(ptouch_dev ptdev); int ptouch_lf(ptouch_dev ptdev);
int ptouch_ff(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); size_t ptouch_get_tape_width(ptouch_dev ptdev);
int ptouch_page_flags(ptouch_dev ptdev, uint8_t page_flags); 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_getstatus(ptouch_dev ptdev);
int ptouch_getmaxwidth(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_enable_packbits(ptouch_dev ptdev);
int ptouch_info_cmd(ptouch_dev ptdev, int size_x); 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_rasterstart(ptouch_dev ptdev);
int ptouch_sendraster(ptouch_dev ptdev, uint8_t *data, size_t len); int ptouch_sendraster(ptouch_dev ptdev, uint8_t *data, size_t len);
void ptouch_rawstatus(uint8_t raw[32]);
void ptouch_list_supported(); 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);

150
po/de.po
View File

@ -8,193 +8,233 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: ptouch-print 1.3.1\n" "Project-Id-Version: ptouch-print 1.3.1\n"
"Report-Msgid-Bugs-To: dominic@familie-radermacher.ch\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: 2015-11-11 09:35+0100\n" "PO-Revision-Date: 2024-05-23 22:27-0400\n"
"Last-Translator: <dominic@familie-radermacher.ch>\n" "Last-Translator: dominic@familie-radermacher.ch\n"
"Language-Team: German <translation-team-de@lists.sourceforge.net>\n" "Language-Team: German <translation-team-de@lists.sourceforge.net>\n"
"Language: de\n" "Language: de\n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\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 #, c-format
msgid "out of memory\n" msgid "out of memory\n"
msgstr "Nicht genug Speicher\n" msgstr "Nicht genug Speicher\n"
#: src/libptouch.c:63 #: src/libptouch.c:107
#, c-format #, c-format
msgid "libusb_init() failed\n" msgid "libusb_init() failed\n"
msgstr "ptouch_init() fehlgeschlagen\n" msgstr "ptouch_init() fehlgeschlagen\n"
#: src/libptouch.c:72 #: src/libptouch.c:116
#, c-format #, c-format
msgid "failed to get device descriptor" msgid "failed to get device descriptor"
msgstr "" msgstr ""
#: src/libptouch.c:78 #: src/libptouch.c:122
#, c-format #, c-format
msgid "%s found on USB bus %d, device %d\n" msgid "%s found on USB bus %d, device %d\n"
msgstr "Drucker %s am USB Bus %d, Gerät %d gefunden\n" msgstr "Drucker %s am USB Bus %d, Gerät %d gefunden\n"
#: src/libptouch.c:83 #: src/libptouch.c:137
#, c-format #, c-format
msgid "libusb_open error :%s\n" msgid "libusb_open error :%s\n"
msgstr "" msgstr ""
#: src/libptouch.c:89 #: src/libptouch.c:143
#, c-format #, c-format
msgid "error while detaching kernel driver: %s\n" msgid "error while detaching kernel driver: %s\n"
msgstr "" msgstr ""
#: src/libptouch.c:93 #: src/libptouch.c:147
#, c-format #, c-format
msgid "interface claim error: %s\n" msgid "interface claim error: %s\n"
msgstr "" msgstr ""
#: src/libptouch.c:101 #: src/libptouch.c:158
#, c-format #, c-format
msgid "" msgid "No P-Touch printer found on USB (remember to put switch to position E)\n"
"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" msgstr "Kein P-Ptouch Drucker am USB gefunden (Schalter muss auf E stehen)\n"
#: src/libptouch.c:121 #: src/libptouch.c:178
#, c-format #, c-format
msgid "write error: %s\n" msgid "write error: %s\n"
msgstr "" msgstr ""
#: src/libptouch.c:125 #: src/libptouch.c:182
#, c-format #, fuzzy, c-format
msgid "write error: could send only %i of %i bytes\n" #| msgid "read error: got %i instead of 32 bytes\n"
msgstr "" 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 #, c-format
msgid "debug: dumping raw status bytes\n" msgid "debug: dumping raw status bytes\n"
msgstr "" msgstr ""
#: src/libptouch.c:218 src/libptouch.c:263 #: src/libptouch.c:326 src/libptouch.c:362
#, c-format #, c-format
msgid "read error: %s\n" msgid "read error: %s\n"
msgstr "" msgstr ""
#: src/libptouch.c:223 #: src/libptouch.c:331
#, c-format #, c-format
msgid "timeout while waiting for status response\n" msgid "timeout while waiting for status response\n"
msgstr "" msgstr ""
#: src/libptouch.c:231 #: src/libptouch.c:345
#, 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
#, c-format #, c-format
msgid "unknown tape width of %imm, please report this.\n" msgid "unknown tape width of %imm, please report this.\n"
msgstr "Unbekannte Schriftband breite (%i mm), bitte melden\n" msgstr "Unbekannte Schriftband breite (%i mm), bitte melden\n"
#: src/libptouch.c:252 #: src/libptouch.c:351
#, c-format #, c-format
msgid "got only 16 bytes... wondering what they are:\n" msgid "got only 16 bytes... wondering what they are:\n"
msgstr "nur 16 bytes empfangen... mal gucken was die sind:\n" msgstr "nur 16 bytes empfangen... mal gucken was die sind:\n"
#: src/libptouch.c:256 #: src/libptouch.c:355
#, c-format #, c-format
msgid "read error: got %i instead of 32 bytes\n" msgid "read error: got %i instead of 32 bytes\n"
msgstr "Lesefehler: %i anstatt 32 bytes empfangen\n" msgstr "Lesefehler: %i anstatt 32 bytes empfangen\n"
#: src/libptouch.c:259 #: src/libptouch.c:358
#, c-format #, c-format
msgid "strange status:\n" msgid "strange status:\n"
msgstr "Seltsamer Status:\n" msgstr "Seltsamer Status:\n"
#: src/libptouch.c:261 #: src/libptouch.c:360
#, c-format #, c-format
msgid "trying to flush junk\n" msgid "trying to flush junk\n"
msgstr "" msgstr ""
#: src/libptouch.c:266 #: src/libptouch.c:365
#, c-format #, c-format
msgid "got another %i bytes. now try again\n" msgid "got another %i bytes. now try again\n"
msgstr "weitere %i bytes empfangen. probiere es nochmal.\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 #, c-format
msgid "image is too large (%ipx x %ipx)\n" msgid "image is too large (%ipx x %ipx)\n"
msgstr "Bild ist zu gross (%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 #, c-format
msgid "maximum printing width for this tape is %ipx\n" msgid "maximum printing width for this tape is %ipx\n"
msgstr "Maximal druckbare Breite für dieses Schriftband sind %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 #, c-format
msgid "ptouch_rasterstart() failed\n" msgid "ptouch_rasterstart() failed\n"
msgstr "ptouch_rasterstart() fehlgeschlagen\n" msgstr "ptouch_rasterstart() fehlgeschlagen\n"
#: src/ptouch-print.c:88 #: src/ptouch-print.c:110
#, c-format #, 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" msgstr "ptouch_send() fehlgeschlagen\n"
#: src/ptouch-print.c:128 #: src/ptouch-print.c:182
#, c-format #, c-format
msgid "writing image '%s' failed\n" msgid "writing image '%s' failed\n"
msgstr "Schreiben der Bilddatei '%s' fehlgeschlagen\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 #, c-format
msgid "warning: font config not available\n" msgid "warning: font config not available\n"
msgstr "Warnung: fontconfig ist nicht verfügbar\n" msgstr "Warnung: fontconfig ist nicht verfügbar\n"
#: src/ptouch-print.c:201 #: src/ptouch-print.c:273
#, c-format #, c-format
msgid "setting font size=%i\n" msgid "setting font size=%i\n"
msgstr "setze Zeichensatzgrösse=%i\n" msgstr "setze Zeichensatzgrösse=%i\n"
#: src/ptouch-print.c:205 #: src/ptouch-print.c:277
#, c-format #, c-format
msgid "could not estimate needed font size\n" msgid "could not estimate needed font size\n"
msgstr "Konnte die notwendige Zeichensatzgrösse nicht bestimmen\n" msgstr "Konnte die notwendige Zeichensatzgrösse nicht bestimmen\n"
#: src/ptouch-print.c:212 #: src/ptouch-print.c:284
#, c-format #, c-format
msgid "choosing font size=%i\n" msgid "choosing font size=%i\n"
msgstr "Wähle Zeichensatzgrösse %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 #, c-format
msgid "error in gdImageStringFT: %s\n" msgid "error in gdImageStringFT: %s\n"
msgstr "Fehler in Funktion gdImageStringFT(): %s\n" msgstr "Fehler in Funktion gdImageStringFT(): %s\n"
#: src/ptouch-print.c:299 #: src/ptouch-print.c:495
#, c-format #, c-format
msgid "ptouch-print version %s by Dominic Radermacher\n" msgid "ptouch-print version %s by Dominic Radermacher\n"
msgstr "ptouch-print Version %s von Dominic Radermacher\n" msgstr "ptouch-print Version %s von Dominic Radermacher\n"
#: src/ptouch-print.c:326 #: src/ptouch-print.c:526
#, c-format #, c-format
msgid "ptouch_init() failed\n" msgid "ptouch_init() failed\n"
msgstr "ptouch_init() fehlgeschlagen\n" msgstr "ptouch_init() fehlgeschlagen\n"
#: src/ptouch-print.c:329 #: src/ptouch-print.c:529
#, c-format #, c-format
msgid "ptouch_getstatus() failed\n" msgid "ptouch_getstatus() failed\n"
msgstr "ptouch_getstatus() fehlgeschlagen\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 #, c-format
msgid "could not render text\n" msgid "could not render text\n"
msgstr "Konnte Text nicht rendern\n" msgstr "Konnte Text nicht rendern\n"
#: src/ptouch-print.c:389 #: src/ptouch-print.c:616
#, c-format #, c-format
msgid "ptouch_eject() failed\n" msgid "ptouch_finalize(%d) failed\n"
msgstr "ptouch_eject() fehlgeschlagen\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"

152
po/en.po
View File

@ -7,194 +7,232 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: ptouch-print 1.3.1\n" "Project-Id-Version: ptouch-print 1.3.1\n"
"Report-Msgid-Bugs-To: dominic@familie-radermacher.ch\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: 2015-11-11 09:47+0100\n" "PO-Revision-Date: 2024-05-23 22:26-0400\n"
"Last-Translator: <dominic@familie-radermacher.ch>\n" "Last-Translator: dominic@familie-radermacher.ch\n"
"Language-Team: English <en@translate.freefriends.org>\n" "Language-Team: English <en@translate.freefriends.org>\n"
"Language: en\n" "Language: en\n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\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 #, c-format
msgid "out of memory\n" msgid "out of memory\n"
msgstr "out of memory\n" msgstr "out of memory\n"
#: src/libptouch.c:63 #: src/libptouch.c:107
#, c-format #, c-format
msgid "libusb_init() failed\n" msgid "libusb_init() failed\n"
msgstr "libusb_init() failed\n" msgstr "libusb_init() failed\n"
#: src/libptouch.c:72 #: src/libptouch.c:116
#, c-format #, c-format
msgid "failed to get device descriptor" msgid "failed to get device descriptor"
msgstr "failed to get device descriptor" msgstr "failed to get device descriptor"
#: src/libptouch.c:78 #: src/libptouch.c:122
#, c-format #, c-format
msgid "%s found on USB bus %d, device %d\n" msgid "%s found on USB bus %d, device %d\n"
msgstr "%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 #, c-format
msgid "libusb_open error :%s\n" msgid "libusb_open error :%s\n"
msgstr "libusb_open error :%s\n" msgstr "libusb_open error :%s\n"
#: src/libptouch.c:89 #: src/libptouch.c:143
#, c-format #, c-format
msgid "error while detaching kernel driver: %s\n" msgid "error while detaching kernel driver: %s\n"
msgstr "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 #, c-format
msgid "interface claim error: %s\n" msgid "interface claim error: %s\n"
msgstr "interface claim error: %s\n" msgstr "interface claim error: %s\n"
#: src/libptouch.c:101 #: src/libptouch.c:158
#, c-format #, c-format
msgid "" msgid "No P-Touch printer found on USB (remember to put switch to position E)\n"
"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"
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 #, c-format
msgid "write error: %s\n" msgid "write error: %s\n"
msgstr "write error: %s\n" msgstr "write error: %s\n"
#: src/libptouch.c:125 #: src/libptouch.c:182
#, c-format #, fuzzy, c-format
msgid "write error: could send only %i of %i bytes\n" #| 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" msgstr "write error: could send only %i of %i bytes\n"
#: src/libptouch.c:194 #: src/libptouch.c:302
#, c-format #, c-format
msgid "debug: dumping raw status bytes\n" msgid "debug: dumping raw status bytes\n"
msgstr "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 #, c-format
msgid "read error: %s\n" msgid "read error: %s\n"
msgstr "read error: %s\n" msgstr "read error: %s\n"
#: src/libptouch.c:223 #: src/libptouch.c:331
#, c-format #, c-format
msgid "timeout while waiting for status response\n" msgid "timeout while waiting for status response\n"
msgstr "timeout while waiting for status response\n" msgstr "timeout while waiting for status response\n"
#: src/libptouch.c:231 #: src/libptouch.c:345
#, 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
#, c-format #, c-format
msgid "unknown tape width of %imm, please report this.\n" msgid "unknown tape width of %imm, please report this.\n"
msgstr "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 #, c-format
msgid "got only 16 bytes... wondering what they are:\n" msgid "got only 16 bytes... wondering what they are:\n"
msgstr "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 #, c-format
msgid "read error: got %i instead of 32 bytes\n" msgid "read error: got %i instead of 32 bytes\n"
msgstr "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 #, c-format
msgid "strange status:\n" msgid "strange status:\n"
msgstr "strange status:\n" msgstr "strange status:\n"
#: src/libptouch.c:261 #: src/libptouch.c:360
#, c-format #, c-format
msgid "trying to flush junk\n" msgid "trying to flush junk\n"
msgstr "trying to flush junk\n" msgstr "trying to flush junk\n"
#: src/libptouch.c:266 #: src/libptouch.c:365
#, c-format #, c-format
msgid "got another %i bytes. now try again\n" msgid "got another %i bytes. now try again\n"
msgstr "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 #, c-format
msgid "image is too large (%ipx x %ipx)\n" msgid "image is too large (%ipx x %ipx)\n"
msgstr "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 #, c-format
msgid "maximum printing width for this tape is %ipx\n" msgid "maximum printing width for this tape is %ipx\n"
msgstr "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 #, c-format
msgid "ptouch_rasterstart() failed\n" msgid "ptouch_rasterstart() failed\n"
msgstr "ptouch_rasterstart() failed\n" msgstr "ptouch_rasterstart() failed\n"
#: src/ptouch-print.c:88 #: src/ptouch-print.c:110
#, c-format #, c-format
msgid "ptouch_send() failed\n" msgid "send print information command\n"
msgstr "ptouch_send() failed\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 #, c-format
msgid "writing image '%s' failed\n" msgid "writing image '%s' failed\n"
msgstr "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 #, c-format
msgid "warning: font config not available\n" msgid "warning: font config not available\n"
msgstr "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 #, c-format
msgid "setting font size=%i\n" msgid "setting font size=%i\n"
msgstr "setting font size=%i\n" msgstr "setting font size=%i\n"
#: src/ptouch-print.c:205 #: src/ptouch-print.c:277
#, c-format #, c-format
msgid "could not estimate needed font size\n" msgid "could not estimate needed font size\n"
msgstr "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 #, c-format
msgid "choosing font size=%i\n" msgid "choosing font size=%i\n"
msgstr "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 #, c-format
msgid "error in gdImageStringFT: %s\n" msgid "error in gdImageStringFT: %s\n"
msgstr "error in gdImageStringFT: %s\n" msgstr "error in gdImageStringFT: %s\n"
#: src/ptouch-print.c:299 #: src/ptouch-print.c:495
#, c-format #, c-format
msgid "ptouch-print version %s by Dominic Radermacher\n" msgid "ptouch-print version %s by Dominic Radermacher\n"
msgstr "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 #, c-format
msgid "ptouch_init() failed\n" msgid "ptouch_init() failed\n"
msgstr "ptouch_init() failed\n" msgstr "ptouch_init() failed\n"
#: src/ptouch-print.c:329 #: src/ptouch-print.c:529
#, c-format #, c-format
msgid "ptouch_getstatus() failed\n" msgid "ptouch_getstatus() failed\n"
msgstr "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 #, c-format
msgid "could not render text\n" msgid "could not render text\n"
msgstr "could not render text\n" msgstr "could not render text\n"
#: src/ptouch-print.c:389 #: src/ptouch-print.c:616
#, c-format #, c-format
msgid "ptouch_eject() failed\n" msgid "ptouch_finalize(%d) failed\n"
msgstr "ptouch_eject() 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"

View File

@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: ptouch 1.3.3\n" "Project-Id-Version: ptouch 1.3.3\n"
"Report-Msgid-Bugs-To: dominic@familie-radermacher.ch\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" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -17,183 +17,213 @@ msgstr ""
"Content-Type: text/plain; charset=CHARSET\n" "Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
#: src/libptouch.c:59 #: src/libptouch.c:95 src/libptouch.c:99 src/libptouch.c:103
#, c-format #, c-format
msgid "out of memory\n" msgid "out of memory\n"
msgstr "" msgstr ""
#: src/libptouch.c:63 #: src/libptouch.c:107
#, c-format #, c-format
msgid "libusb_init() failed\n" msgid "libusb_init() failed\n"
msgstr "" msgstr ""
#: src/libptouch.c:72 #: src/libptouch.c:116
#, c-format #, c-format
msgid "failed to get device descriptor" msgid "failed to get device descriptor"
msgstr "" msgstr ""
#: src/libptouch.c:78 #: src/libptouch.c:122
#, c-format #, c-format
msgid "%s found on USB bus %d, device %d\n" msgid "%s found on USB bus %d, device %d\n"
msgstr "" msgstr ""
#: src/libptouch.c:83 #: src/libptouch.c:137
#, c-format #, c-format
msgid "libusb_open error :%s\n" msgid "libusb_open error :%s\n"
msgstr "" msgstr ""
#: src/libptouch.c:89 #: src/libptouch.c:143
#, c-format #, c-format
msgid "error while detaching kernel driver: %s\n" msgid "error while detaching kernel driver: %s\n"
msgstr "" msgstr ""
#: src/libptouch.c:93 #: src/libptouch.c:147
#, c-format #, c-format
msgid "interface claim error: %s\n" msgid "interface claim error: %s\n"
msgstr "" msgstr ""
#: src/libptouch.c:101 #: src/libptouch.c:158
#, c-format #, c-format
msgid "" msgid ""
"No P-Touch printer found on USB (remember to put switch to position E)\n" "No P-Touch printer found on USB (remember to put switch to position E)\n"
msgstr "" msgstr ""
#: src/libptouch.c:121 #: src/libptouch.c:178
#, c-format #, c-format
msgid "write error: %s\n" msgid "write error: %s\n"
msgstr "" msgstr ""
#: src/libptouch.c:125 #: src/libptouch.c:182
#, c-format #, 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 "" msgstr ""
#: src/libptouch.c:194 #: src/libptouch.c:302
#, c-format #, c-format
msgid "debug: dumping raw status bytes\n" msgid "debug: dumping raw status bytes\n"
msgstr "" msgstr ""
#: src/libptouch.c:218 src/libptouch.c:263 #: src/libptouch.c:326 src/libptouch.c:362
#, c-format #, c-format
msgid "read error: %s\n" msgid "read error: %s\n"
msgstr "" msgstr ""
#: src/libptouch.c:223 #: src/libptouch.c:331
#, c-format #, c-format
msgid "timeout while waiting for status response\n" msgid "timeout while waiting for status response\n"
msgstr "" msgstr ""
#: src/libptouch.c:231 #: src/libptouch.c:345
#, c-format
msgid "Error 1 = %02x\n"
msgstr ""
#: src/libptouch.c:234
#, c-format
msgid "Error 2 = %02x\n"
msgstr ""
#: src/libptouch.c:244
#, c-format #, c-format
msgid "unknown tape width of %imm, please report this.\n" msgid "unknown tape width of %imm, please report this.\n"
msgstr "" msgstr ""
#: src/libptouch.c:252 #: src/libptouch.c:351
#, c-format #, c-format
msgid "got only 16 bytes... wondering what they are:\n" msgid "got only 16 bytes... wondering what they are:\n"
msgstr "" msgstr ""
#: src/libptouch.c:256 #: src/libptouch.c:355
#, c-format #, c-format
msgid "read error: got %i instead of 32 bytes\n" msgid "read error: got %i instead of 32 bytes\n"
msgstr "" msgstr ""
#: src/libptouch.c:259 #: src/libptouch.c:358
#, c-format #, c-format
msgid "strange status:\n" msgid "strange status:\n"
msgstr "" msgstr ""
#: src/libptouch.c:261 #: src/libptouch.c:360
#, c-format #, c-format
msgid "trying to flush junk\n" msgid "trying to flush junk\n"
msgstr "" msgstr ""
#: src/libptouch.c:266 #: src/libptouch.c:365
#, c-format #, c-format
msgid "got another %i bytes. now try again\n" msgid "got another %i bytes. now try again\n"
msgstr "" 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 #, c-format
msgid "image is too large (%ipx x %ipx)\n" msgid "image is too large (%ipx x %ipx)\n"
msgstr "" msgstr ""
#: src/ptouch-print.c:72 src/ptouch-print.c:356 #: src/ptouch-print.c:90 src/ptouch-print.c:556
#, c-format #, c-format
msgid "maximum printing width for this tape is %ipx\n" msgid "maximum printing width for this tape is %ipx\n"
msgstr "" msgstr ""
#: src/ptouch-print.c:77 #: src/ptouch-print.c:104
#, c-format #, c-format
msgid "ptouch_rasterstart() failed\n" msgid "ptouch_rasterstart() failed\n"
msgstr "" msgstr ""
#: src/ptouch-print.c:88 #: src/ptouch-print.c:110
#, c-format #, c-format
msgid "ptouch_send() failed\n" msgid "send print information command\n"
msgstr "" 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 #, c-format
msgid "writing image '%s' failed\n" msgid "writing image '%s' failed\n"
msgstr "" 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 #, c-format
msgid "warning: font config not available\n" msgid "warning: font config not available\n"
msgstr "" msgstr ""
#: src/ptouch-print.c:201 #: src/ptouch-print.c:273
#, c-format #, c-format
msgid "setting font size=%i\n" msgid "setting font size=%i\n"
msgstr "" msgstr ""
#: src/ptouch-print.c:205 #: src/ptouch-print.c:277
#, c-format #, c-format
msgid "could not estimate needed font size\n" msgid "could not estimate needed font size\n"
msgstr "" msgstr ""
#: src/ptouch-print.c:212 #: src/ptouch-print.c:284
#, c-format #, c-format
msgid "choosing font size=%i\n" msgid "choosing font size=%i\n"
msgstr "" msgstr ""
#: src/ptouch-print.c:226 src/ptouch-print.c:232 #: src/ptouch-print.c:300 src/ptouch-print.c:328
#, c-format #, c-format
msgid "error in gdImageStringFT: %s\n" msgid "error in gdImageStringFT: %s\n"
msgstr "" msgstr ""
#: src/ptouch-print.c:299 #: src/ptouch-print.c:495
#, c-format #, c-format
msgid "ptouch-print version %s by Dominic Radermacher\n" msgid "ptouch-print version %s by Dominic Radermacher\n"
msgstr "" msgstr ""
#: src/ptouch-print.c:326 #: src/ptouch-print.c:526
#, c-format #, c-format
msgid "ptouch_init() failed\n" msgid "ptouch_init() failed\n"
msgstr "" msgstr ""
#: src/ptouch-print.c:329 #: src/ptouch-print.c:529
#, c-format #, c-format
msgid "ptouch_getstatus() failed\n" msgid "ptouch_getstatus() failed\n"
msgstr "" 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 #, c-format
msgid "could not render text\n" msgid "could not render text\n"
msgstr "" msgstr ""
#: src/ptouch-print.c:389 #: src/ptouch-print.c:616
#, c-format #, c-format
msgid "ptouch_eject() failed\n" msgid "ptouch_finalize(%d) failed\n"
msgstr "" msgstr ""

View File

@ -1,10 +1,10 @@
.\" Man page for ptouch-print .\" 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. .\" 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 .SH NAME
ptouch-print \- a command line tool to use Brother Ptouch label printers ptouch-print \- a command line tool to use Brother Ptouch label printers
.SH SYNOPSIS .SH SYNOPSIS
@ -76,6 +76,9 @@ Display version information and exit.
.TP .TP
.BR \-\-info .BR \-\-info
Show info about the tape detected (like printing width etc.) and exit. Show info about the tape detected (like printing width etc.) and exit.
.TP
.BR \-\-list-supported
List all supported printers
.SH DEFAULTS .SH DEFAULTS
The default font used is 'DejaVuSans'. The default font used is 'DejaVuSans'.
@ -109,4 +112,4 @@ The image file must be palette based PNG format with two colors.
.SH AUTHOR .SH AUTHOR
Written by Dominic Radermacher (dominic@familie-radermacher.ch). 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/

View File

@ -1,7 +1,7 @@
/* /*
libptouch - functions to help accessing a brother ptouch libptouch - functions to help accessing a brother ptouch
Copyright (C) 2013-2021 Dominic Radermacher <dominic@familie-radermacher.ch> Copyright (C) 2013-2025 Dominic Radermacher <dominic@familie-radermacher.ch>
This program is free software; you can redistribute it and/or modify it 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 under the terms of the GNU General Public License version 3 as
@ -21,7 +21,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> /* malloc() */ #include <stdlib.h> /* malloc() */
#include <string.h> /* memcmp() */ #include <string.h> /* memcmp() */
#include <sys/types.h> /* open() */ #include <sys/types.h> /* open() */
#include <sys/stat.h> /* open() */ #include <sys/stat.h> /* open() */
#include <fcntl.h> /* open() */ #include <fcntl.h> /* open() */
@ -45,10 +45,11 @@ struct _pt_tape_info tape_info[]= {
}; };
struct _pt_dev_info ptdevs[] = { 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, 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, 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_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! */ {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 /* Notes about the PT-1230PC: While it is true that this printer supports
max 12mm tapes, it apparently expects > 76px data - the first 32px max 12mm tapes, it apparently expects > 76px data - the first 32px
@ -65,22 +66,23 @@ struct _pt_dev_info ptdevs[] = {
{0x04f9, 0x205f, "PT-E500", 128, 180, FLAG_RASTER_PACKBITS}, {0x04f9, 0x205f, "PT-E500", 128, 180, FLAG_RASTER_PACKBITS},
/* Note about the PT-E500: was reported by Jesse Becker with the /* Note about the PT-E500: was reported by Jesse Becker with the
remark that it also needs some padding (white pixels) */ 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, 0x2062, "PT-P750W", 128, 180, FLAG_RASTER_PACKBITS|FLAG_P700_INIT},
{0x04f9, 0x2064, "PT-P700 (PLite Mode)", 128, 180, FLAG_PLITE}, {0x04f9, 0x2064, "PT-P700 (PLite Mode)", 128, 180, FLAG_PLITE},
{0x04f9, 0x2065, "PT-P750W (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}, {0x04f9, 0x2073, "PT-D450", 128, 180, FLAG_USE_INFO_CMD},
/* Notes about the PT-D450: I'm unsure if print width really is 128px */ /* 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}, {0x04f9, 0x2074, "PT-D600", 128, 180, FLAG_RASTER_PACKBITS},
/* PT-D600 was reported to work, but with some quirks (premature /* PT-D600 was reported to work, but with some quirks (premature
cutting of tape, printing maximum of 73mm length) */ 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, 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} {0,0,"",0,0,0}
}; };
void ptouch_rawstatus(uint8_t raw[32]);
int ptouch_open(ptouch_dev *ptdev) int ptouch_open(ptouch_dev *ptdev)
{ {
libusb_device **devs; libusb_device **devs;
@ -116,7 +118,7 @@ int ptouch_open(ptouch_dev *ptdev)
libusb_free_device_list(devs, 1); libusb_free_device_list(devs, 1);
return -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)) { 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"), fprintf(stderr, _("%s found on USB bus %d, device %d\n"),
ptdevs[k].name, ptdevs[k].name,
@ -186,8 +188,35 @@ int ptouch_send(ptouch_dev ptdev, uint8_t *data, size_t len)
int ptouch_init(ptouch_dev ptdev) int ptouch_init(ptouch_dev ptdev)
{ {
char cmd[]="\x1b\x40"; /* 1B 40 = ESC @ = INIT */ /* first invalidate, then send init command */
return ptouch_send(ptdev, (uint8_t *)cmd, strlen(cmd)); uint8_t cmd[102];
memset(cmd, 0, 100);
cmd[100] = 0x1b; /* ESC */
cmd[101] = 0x40; /* @ */
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)
{
/* 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) int ptouch_enable_packbits(ptouch_dev ptdev)
@ -214,9 +243,26 @@ int ptouch_info_cmd(ptouch_dev ptdev, int size_x)
cmd[8] = (uint8_t) (size_x >> 8) & 0xff; cmd[8] = (uint8_t) (size_x >> 8) & 0xff;
cmd[9] = (uint8_t) (size_x >> 16) & 0xff; cmd[9] = (uint8_t) (size_x >> 16) & 0xff;
cmd[10] = (uint8_t) (size_x >> 24) & 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); 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, (uint8_t *)cmd, sizeof(cmd)-1);
}
int ptouch_rasterstart(ptouch_dev ptdev) int ptouch_rasterstart(ptouch_dev ptdev)
{ {
/* 1B 69 52 01 = Select graphics transfer mode = Raster */ /* 1B 69 52 01 = Select graphics transfer mode = Raster */
@ -243,17 +289,22 @@ int ptouch_ff(ptouch_dev ptdev)
return ptouch_send(ptdev, (uint8_t *)cmd, strlen(cmd)); return ptouch_send(ptdev, (uint8_t *)cmd, strlen(cmd));
} }
/* print and cut tape */ /* finish print and either cut or leave tape in machine */
int ptouch_eject(ptouch_dev ptdev) int ptouch_finalize(ptouch_dev ptdev, int chain)
{ {
char cmd[]="\x1a"; char cmd_eject[]="\x1a"; /* Print command with feeding */
return ptouch_send(ptdev, (uint8_t *)cmd, strlen(cmd)); char cmd_chain[]="\x0c"; /* Print command (no cut) */
// 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);
} }
void ptouch_rawstatus(uint8_t raw[32]) void ptouch_rawstatus(uint8_t raw[32])
{ {
fprintf(stderr, _("debug: dumping raw status bytes\n")); 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]); fprintf(stderr, "%02x ", raw[i]);
if (((i+1) % 16) == 0) { if (((i+1) % 16) == 0) {
fprintf(stderr, "\n"); fprintf(stderr, "\n");
@ -266,7 +317,7 @@ void ptouch_rawstatus(uint8_t raw[32])
int ptouch_getstatus(ptouch_dev ptdev) int ptouch_getstatus(ptouch_dev ptdev)
{ {
char cmd[]="\x1biS"; /* 1B 69 53 = ESC i S = Status info request */ 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; int i, r, tx=0, tries=0;
struct timespec w; struct timespec w;
@ -279,7 +330,7 @@ int ptouch_getstatus(ptouch_dev ptdev)
fprintf(stderr, _("read error: %s\n"), libusb_error_name(r)); fprintf(stderr, _("read error: %s\n"), libusb_error_name(r));
return -1; return -1;
} }
tries++; ++tries;
if (tries > 10) { if (tries > 10) {
fprintf(stderr, _("timeout while waiting for status response\n")); fprintf(stderr, _("timeout while waiting for status response\n"));
return -1; return -1;
@ -289,7 +340,7 @@ int ptouch_getstatus(ptouch_dev ptdev)
if (buf[0]==0x80 && buf[1]==0x20) { if (buf[0]==0x80 && buf[1]==0x20) {
memcpy(ptdev->status, buf, 32); memcpy(ptdev->status, buf, 32);
ptdev->tape_width_px=0; 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]) { if (tape_info[i].mm == buf[10]) {
ptdev->tape_width_px=tape_info[i].px; ptdev->tape_width_px=tape_info[i].px;
} }
@ -357,10 +408,80 @@ int ptouch_sendraster(ptouch_dev ptdev, uint8_t *data, size_t len)
void ptouch_list_supported() void ptouch_list_supported()
{ {
printf("Supported printers (some might have quirks)\n"); 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) { if ((ptdevs[i].flags & FLAG_PLITE) != FLAG_PLITE) {
printf("\t%s\n", ptdevs[i].name); printf("\t%s\n", ptdevs[i].name);
} }
} }
return; 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";
}
}

View File

@ -1,7 +1,7 @@
/* /*
ptouch-print - Print labels with images or text on a Brother P-Touch ptouch-print - Print labels with images or text on a Brother P-Touch
Copyright (C) 2015-2021 Dominic Radermacher <dominic@familie-radermacher.ch> Copyright (C) 2015-2025 Dominic Radermacher <dominic@familie-radermacher.ch>
This program is free software; you can redistribute it and/or modify it 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 under the terms of the GNU General Public License version 3 as
@ -41,22 +41,24 @@ void rasterline_setpixel(uint8_t* rasterline, size_t size, int pixel);
int get_baselineoffset(char *text, char *font, int fsz); int get_baselineoffset(char *text, char *font, int fsz);
int find_fontsize(int want_px, char *font, char *text); int find_fontsize(int want_px, char *font, char *text);
int needed_width(char *text, char *font, int fsz); 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); int write_png(gdImage *im, const char *file);
gdImage *img_append(gdImage *in_1, gdImage *in_2); gdImage *img_append(gdImage *in_1, gdImage *in_2);
gdImage *img_cutmark(int tape_width); gdImage *img_cutmark(int print_width);
gdImage *render_text(char *font, char *line[], int lines, int tape_width); gdImage *render_text(char *font, char *line[], int lines, int print_width);
void unsupported_printer(ptouch_dev ptdev); void unsupported_printer(ptouch_dev ptdev);
void usage(char *progname); void usage(char *progname);
int parse_args(int argc, char **argv); int parse_args(int argc, char **argv);
// char *font_file="/usr/share/fonts/TTF/Ubuntu-M.ttf"; // char *font_file = "/usr/share/fonts/TTF/Ubuntu-M.ttf";
// char *font_file="Ubuntu:medium"; // char *font_file = "Ubuntu:medium";
char *font_file="DejaVuSans"; char *font_file = "DejaVuSans";
char *save_png=NULL; char *save_png = NULL;
int verbose=0; int verbose = 0;
int fontsize=0; int fontsize = 0;
bool debug=false; bool debug = false;
bool chain = false;
int forced_print_width = 0;
/* -------------------------------------------------------------------- /* --------------------------------------------------------------------
-------------------------------------------------------------------- */ -------------------------------------------------------------------- */
@ -65,36 +67,38 @@ void rasterline_setpixel(uint8_t* rasterline, size_t size, int pixel)
{ {
// TODO: pixel should be unsigned, since we can't have negative // TODO: pixel should be unsigned, since we can't have negative
// if (pixel > ptdev->devinfo->device_max_px) { // if (pixel > ptdev->devinfo->device_max_px) {
if (pixel > (int)(size*8)) { if ((pixel < 0) || (pixel >= (int)(size*8))) {
return; return;
} }
rasterline[(size-1)-(pixel/8)] |= (uint8_t)(1<<(pixel%8)); rasterline[(size-1)-(pixel/8)] |= (uint8_t)(1<<(pixel%8));
return; 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]; uint8_t rasterline[(ptdev->devinfo->max_px)/8];
if (!im) { if (!im) {
printf(_("nothing to print\n")); printf(_("nothing to print\n"));
return -1; 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 */ /* 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) { if (gdImageSY(im) > tape_width) {
printf(_("image is too large (%ipx x %ipx)\n"), gdImageSX(im), gdImageSY(im)); 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); printf(_("maximum printing width for this tape is %ipx\n"), tape_width);
return -1; return -1;
} }
offset=64-(gdImageSY(im)/2); /* always print centered */ printf(_("image size (%ipx x %ipx)\n"), gdImageSX(im), gdImageSY(im));
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 ((ptdev->devinfo->flags & FLAG_RASTER_PACKBITS) == FLAG_RASTER_PACKBITS) {
if (debug) { if (debug) {
printf("enable PackBits mode\n"); printf("enable PackBits mode\n");
} }
ptouch_enable_packbits(ptdev); ptouch_enable_packbits(ptdev);
} }
if (ptouch_rasterstart(ptdev) != 0) { if (ptouch_rasterstart(ptdev) != 0) {
printf(_("ptouch_rasterstart() failed\n")); printf(_("ptouch_rasterstart() failed\n"));
@ -106,14 +110,32 @@ int print_img(ptouch_dev ptdev, gdImage *im)
printf(_("send print information command\n")); printf(_("send print information command\n"));
} }
} }
for (k=0; k<gdImageSX(im); k+=1) { 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"));
}
}
if ((ptdev->devinfo->flags & FLAG_HAS_PRECUT) == FLAG_HAS_PRECUT) {
ptouch_send_precut_cmd(ptdev, 1);
if (debug) {
printf(_("send precut command\n"));
}
}
for (int k = 0; k < gdImageSX(im); ++k) {
memset(rasterline, 0, sizeof(rasterline)); memset(rasterline, 0, sizeof(rasterline));
for (i=0; i<gdImageSY(im); i+=1) { for (int i = 0; i < gdImageSY(im); ++i) {
if (gdImageGetPixel(im, k, gdImageSY(im)-1-i) == d) { if (gdImageGetPixel(im, k, gdImageSY(im) - 1 - i) == d) {
rasterline_setpixel(rasterline, sizeof(rasterline), offset+i); 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")); printf(_("ptouch_sendraster() failed\n"));
return -1; return -1;
} }
@ -130,28 +152,28 @@ int print_img(ptouch_dev ptdev, gdImage *im)
gdImage *image_load(const char *file) 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]; char d[10];
FILE *f; FILE *f;
gdImage *img=NULL; gdImage *img = NULL;
if (!strcmp(file, "-")) { if (!strcmp(file, "-")) {
f = stdin; f = stdin;
} else { } else {
f = fopen(file, "rb"); f = fopen(file, "rb");
} }
if (f == NULL) { /* error could not open file */ if (f == NULL) { /* error could not open file */
return NULL; return NULL;
} }
if (fseek(f, 0L, SEEK_SET)) { /* file is not seekable. eg 'stdin' */ if (fseek(f, 0L, SEEK_SET)) { /* file is not seekable. eg 'stdin' */
img=gdImageCreateFromPng(f); img = gdImageCreateFromPng(f);
} else { } else {
if (fread(d, sizeof(d), 1, f) != 1) { if (fread(d, sizeof(d), 1, f) != 1) {
return NULL; return NULL;
} }
rewind(f); rewind(f);
if (memcmp(d, png, 8) == 0) { if (memcmp(d, png, 8) == 0) {
img=gdImageCreateFromPng(f); img = gdImageCreateFromPng(f);
} }
} }
fclose(f); fclose(f);
@ -179,13 +201,16 @@ int get_baselineoffset(char *text, char *font, int fsz)
{ {
int brect[8]; int brect[8];
if (strpbrk(text, "QgjpqyQµ") == NULL) { /* if we have none of these */ /* NOTE: This assumes that 'o' is always on the baseline */
return 0; /* we don't need an baseline offset */
} /* else we need to calculate it */
gdImageStringFT(NULL, &brect[0], -1, font, fsz, 0.0, 0, 0, "o"); gdImageStringFT(NULL, &brect[0], -1, font, fsz, 0.0, 0, 0, "o");
int tmp=brect[1]-brect[5]; int o_offset = brect[1];
gdImageStringFT(NULL, &brect[0], -1, font, fsz, 0.0, 0, 0, "g"); gdImageStringFT(NULL, &brect[0], -1, font, fsz, 0.0, 0, 0, text);
return (brect[1]-brect[5])-tmp; 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);
}
return text_offset-o_offset;
} }
/* -------------------------------------------------------------------- /* --------------------------------------------------------------------
@ -195,15 +220,15 @@ int get_baselineoffset(char *text, char *font, int fsz)
-------------------------------------------------------------------- */ -------------------------------------------------------------------- */
int find_fontsize(int want_px, char *font, char *text) int find_fontsize(int want_px, char *font, char *text)
{ {
int save=0; int save = 0;
int brect[8]; 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) { if (gdImageStringFT(NULL, &brect[0], -1, font, i, 0.0, 0, 0, text) != NULL) {
break; break;
} }
if (brect[1]-brect[5] <= want_px) { if (brect[1]-brect[5] <= want_px) {
save=i; save = i;
} else { } else {
break; break;
} }
@ -224,12 +249,22 @@ int needed_width(char *text, char *font, int fsz)
return brect[2]-brect[0]; return brect[2]-brect[0];
} }
gdImage *render_text(char *font, char *line[], int lines, int tape_width) int offset_x(char *text, char *font, int fsz)
{ {
int brect[8]; int brect[8];
int i, black, x=0, tmp=0, fsz=0;
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 print_width)
{
int brect[8];
int i, black, x = 0, tmp = 0, fsz = 0;
char *p; char *p;
gdImage *im=NULL; gdImage *im = NULL;
if (debug) { if (debug) {
printf(_("render_text(): %i lines, font = '%s'\n"), lines, font); printf(_("render_text(): %i lines, font = '%s'\n"), lines, font);
@ -238,11 +273,11 @@ gdImage *render_text(char *font, char *line[], int lines, int tape_width)
printf(_("warning: font config not available\n")); printf(_("warning: font config not available\n"));
} }
if (fontsize > 0) { if (fontsize > 0) {
fsz=fontsize; fsz = fontsize;
printf(_("setting font size=%i\n"), fsz); printf(_("setting font size=%i\n"), fsz);
} else { } else {
for (i=0; i<lines; i++) { for (i = 0; i < lines; ++i) {
if ((tmp=find_fontsize(tape_width/lines, font, line[i])) < 0) { if ((tmp = find_fontsize(print_width/lines, font, line[i])) < 0) {
printf(_("could not estimate needed font size\n")); printf(_("could not estimate needed font size\n"));
return NULL; return NULL;
} }
@ -252,39 +287,48 @@ gdImage *render_text(char *font, char *line[], int lines, int tape_width)
} }
printf(_("choosing font size=%i\n"), fsz); printf(_("choosing font size=%i\n"), fsz);
} }
for(i=0; i<lines; i++) { for(i = 0; i < lines; ++i) {
tmp=needed_width(line[i], font_file, fsz); tmp = needed_width(line[i], font_file, fsz);
if (tmp > x) { if (tmp > x) {
x=tmp; x = tmp;
} }
} }
im=gdImageCreatePalette(x, tape_width); im = gdImageCreatePalette(x, print_width);
gdImageColorAllocate(im, 255, 255, 255); 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) */ /* gdImageStringFT(im,brect,fg,fontlist,size,angle,x,y,string) */
/* find max needed line height for ALL lines */ /* find max needed line height for ALL lines */
int max_height=0; int max_height=0;
for (i=0; i<lines; i++) { for (i = 0; i < lines; ++i) {
if ((p=gdImageStringFT(NULL, &brect[0], -black, font, fsz, 0.0, 0, 0, line[i])) != NULL) { if ((p = gdImageStringFT(NULL, &brect[0], -black, font, fsz, 0.0, 0, 0, line[i])) != NULL) {
printf(_("error in gdImageStringFT: %s\n"), p); printf(_("error in gdImageStringFT: %s\n"), p);
} }
//int ofs=get_baselineoffset(line[i], font_file, fsz); //int ofs = get_baselineoffset(line[i], font_file, fsz);
int lineheight=brect[1]-brect[5]; int lineheight = brect[1]-brect[5];
if (lineheight > max_height) { if (lineheight > max_height) {
max_height=lineheight; max_height = lineheight;
} }
} }
if (debug) { if (debug) {
printf("debug: needed (max) height is %ipx\n", max_height); printf("debug: needed (max) height is %ipx\n", max_height);
} }
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 = print_width - (max_height * lines);
/* now render lines */ /* now render lines */
for (i=0; i<lines; i++) { for (i = 0; i < lines; ++i) {
int ofs=get_baselineoffset(line[i], font_file, fsz); int ofs = get_baselineoffset(line[i], font_file, fsz);
int pos=((i)*(tape_width/(lines)))+(max_height)-ofs-1; //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 (debug) {
printf("debug: line %i pos=%i ofs=%i\n", i+1, pos, ofs); 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); printf(_("error in gdImageStringFT: %s\n"), p);
} }
} }
@ -293,27 +337,27 @@ gdImage *render_text(char *font, char *line[], int lines, int tape_width)
gdImage *img_append(gdImage *in_1, gdImage *in_2) gdImage *img_append(gdImage *in_1, gdImage *in_2)
{ {
gdImage *out=NULL; gdImage *out = NULL;
int width=0; int width = 0;
int i_1_x=0; int i_1_x = 0;
int length=0; int length = 0;
if (in_1 != NULL) { if (in_1 != NULL) {
width=gdImageSY(in_1); width = gdImageSY(in_1);
length=gdImageSX(in_1); length = gdImageSX(in_1);
i_1_x=gdImageSX(in_1); i_1_x = gdImageSX(in_1);
} }
if (in_2 != NULL) { if (in_2 != NULL) {
length += gdImageSX(in_2); length += gdImageSX(in_2);
/* width should be the same, but let's be sure */ /* width should be the same, but let's be sure */
if (gdImageSY(in_2) > width) { if (gdImageSY(in_2) > width) {
width=gdImageSY(in_2); width = gdImageSY(in_2);
} }
} }
if ((width == 0) || (length == 0)) { if ((width == 0) || (length == 0)) {
return NULL; return NULL;
} }
out=gdImageCreatePalette(length, width); out = gdImageCreatePalette(length, width);
if (out == NULL) { if (out == NULL) {
return NULL; return NULL;
} }
@ -337,36 +381,36 @@ gdImage *img_append(gdImage *in_1, gdImage *in_2)
return out; return out;
} }
gdImage *img_cutmark(int tape_width) gdImage *img_cutmark(int print_width)
{ {
gdImage *out=NULL; gdImage *out = NULL;
int style_dashed[6]; int style_dashed[6];
out=gdImageCreatePalette(9, tape_width); out = gdImageCreatePalette(9, print_width);
if (out == NULL) { if (out == NULL) {
return NULL; return NULL;
} }
gdImageColorAllocate(out, 255, 255, 255); gdImageColorAllocate(out, 255, 255, 255);
int black=gdImageColorAllocate(out, 0, 0, 0); int black = gdImageColorAllocate(out, 0, 0, 0);
style_dashed[0]=gdTransparent; style_dashed[0] = gdTransparent;
style_dashed[1]=gdTransparent; style_dashed[1] = gdTransparent;
style_dashed[2]=gdTransparent; style_dashed[2] = gdTransparent;
style_dashed[3]=black; style_dashed[3] = black;
style_dashed[4]=black; style_dashed[4] = black;
style_dashed[5]=black; style_dashed[5] = black;
gdImageSetStyle(out, style_dashed, 6); 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; 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)) { if ((length < 1) || (length > 256)) {
length=1; length=1;
} }
out=gdImageCreatePalette(length, tape_width); out = gdImageCreatePalette(length, print_width);
if (out == NULL) { if (out == NULL) {
return NULL; return NULL;
} }
@ -382,6 +426,9 @@ void usage(char *progname)
printf("\t--font <file>\t\tuse font <file> or <name>\n"); printf("\t--font <file>\t\tuse font <file> or <name>\n");
printf("\t--fontsize <size>\tManually set fontsize\n"); printf("\t--fontsize <size>\tManually set fontsize\n");
printf("\t--writepng <file>\tinstead of printing, write output to png file\n"); printf("\t--writepng <file>\tinstead of printing, write output to png file\n");
printf("\t--force-tape-width <px>\tSet tape width in pixels, use together with\n");
printf("\t\t\t\t--writepng without a printer connected.\n");
printf("\t--copies <number>\tSets the number of identical prints\n");
printf("print commands:\n"); printf("print commands:\n");
printf("\t--image <file>\t\tprint the given image which must be a 2 color\n"); printf("\t--image <file>\t\tprint the given image which must be a 2 color\n");
printf("\t\t\t\t(black/white) png\n"); printf("\t\t\t\t(black/white) png\n");
@ -389,6 +436,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\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--cutmark\t\tPrint a mark where the tape should be cut\n");
printf("\t--pad <n>\t\tAdd n pixels padding (blank tape)\n"); printf("\t--pad <n>\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("other commands:\n");
printf("\t--version\t\tshow version info (required for bug report)\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--info\t\t\tshow info about detected tape\n");
@ -401,52 +449,66 @@ int parse_args(int argc, char **argv)
{ {
int lines, i; int lines, i;
for (i=1; i<argc; i++) { for (i = 1; i < argc; ++i) {
if (*argv[i] != '-') { if (*argv[i] != '-') {
break; break;
} }
if (strcmp(&argv[i][1], "-font") == 0) { if (strcmp(&argv[i][1], "-font") == 0) {
if (i+1<argc) { if (i+1 < argc) {
font_file=argv[++i]; font_file = argv[++i];
} else { } else {
usage(argv[0]); usage(argv[0]);
} }
} else if (strcmp(&argv[i][1], "-fontsize") == 0) { } else if (strcmp(&argv[i][1], "-fontsize") == 0) {
if (i+1<argc) { if (i+1 < argc) {
i++; ++i;
} else { } else {
usage(argv[0]); usage(argv[0]);
} }
} else if (strcmp(&argv[i][1], "-writepng") == 0) { } else if (strcmp(&argv[i][1], "-writepng") == 0) {
if (i+1<argc) { if (i+1 < argc) {
save_png=argv[++i]; save_png = argv[++i];
} else {
usage(argv[0]);
}
} else if (strcmp(&argv[i][1], "-force-tape-width") == 0) {
if (i+1 < argc) {
forced_print_width = strtol(argv[++i], NULL, 10);
} else { } else {
usage(argv[0]); usage(argv[0]);
} }
} else if (strcmp(&argv[i][1], "-cutmark") == 0) { } else if (strcmp(&argv[i][1], "-cutmark") == 0) {
continue; /* not done here */ continue; /* not done here */
} else if (strcmp(&argv[i][1], "-chain") == 0) {
chain = true;
} else if (strcmp(&argv[i][1], "-debug") == 0) { } else if (strcmp(&argv[i][1], "-debug") == 0) {
debug=true; debug = true;
} else if (strcmp(&argv[i][1], "-info") == 0) { } else if (strcmp(&argv[i][1], "-info") == 0) {
continue; /* not done here */ 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) { } else if (strcmp(&argv[i][1], "-image") == 0) {
if (i+1<argc) { if (i+1 < argc) {
i++; ++i;
} else { } else {
usage(argv[0]); usage(argv[0]);
} }
} else if (strcmp(&argv[i][1], "-pad") == 0) { } else if (strcmp(&argv[i][1], "-pad") == 0) {
if (i+1<argc) { if (i+1 < argc) {
i++; ++i;
} else { } else {
usage(argv[0]); usage(argv[0]);
} }
} else if (strcmp(&argv[i][1], "-text") == 0) { } 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] == '-')) { if ((i+1 >= argc) || (argv[i+1][0] == '-')) {
break; break;
} }
i++; ++i;
} }
} else if (strcmp(&argv[i][1], "-version") == 0) { } else if (strcmp(&argv[i][1], "-version") == 0) {
printf(_("ptouch-print version %s by Dominic Radermacher\n"), VERSION); printf(_("ptouch-print version %s by Dominic Radermacher\n"), VERSION);
@ -458,103 +520,128 @@ int parse_args(int argc, char **argv)
usage(argv[0]); usage(argv[0]);
} }
} }
if (forced_print_width && !save_png) {
forced_print_width = 0;
}
return i; return i;
} }
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
int i, lines = 0, tape_width; int i, lines = 0, copies = 1, print_width = 0;
char *line[MAX_LINES]; char *line[MAX_LINES];
gdImage *im=NULL; gdImage *im = NULL;
gdImage *out=NULL; gdImage *out = NULL;
ptouch_dev ptdev=NULL; ptouch_dev ptdev = NULL;
setlocale(LC_ALL, ""); setlocale(LC_ALL, "");
bindtextdomain("ptouch-print", "/usr/share/locale/"); bindtextdomain("ptouch-print", "/usr/share/locale/");
textdomain("ptouch-print"); textdomain("ptouch-print");
i=parse_args(argc, argv); i = parse_args(argc, argv);
if (i != argc) { if (i != argc) {
usage(argv[0]); usage(argv[0]);
} }
if ((ptouch_open(&ptdev)) < 0) { int tape_width = ptouch_get_tape_width(ptdev);
return 5; int max_print_width = ptouch_get_max_width(ptdev);
if (!forced_print_width) {
if ((ptouch_open(&ptdev)) < 0) {
return 5;
}
if (ptouch_init(ptdev) != 0) {
printf(_("ptouch_init() failed\n"));
}
if (ptouch_getstatus(ptdev) != 0) {
printf(_("ptouch_getstatus() failed\n"));
return 1;
}
print_width = tape_width;
} else {
print_width = forced_print_width;
} }
if (ptouch_init(ptdev) != 0) { // do not try to print more pixels than printhead has
printf(_("ptouch_init() failed\n")); if (print_width > max_print_width) {
print_width = max_print_width;
} }
if (ptouch_getstatus(ptdev) != 0) { for (i = 1; i < argc; ++i) {
printf(_("ptouch_getstatus() failed\n"));
return 1;
}
tape_width=ptouch_get_tape_width(ptdev);
for (i=1; i<argc; i++) {
if (*argv[i] != '-') { if (*argv[i] != '-') {
break; break;
} }
if (strcmp(&argv[i][1], "-font") == 0) { if (strcmp(&argv[i][1], "-font") == 0) {
if (i+1<argc) { if (i+1 < argc) {
font_file=argv[++i]; font_file = argv[++i];
} else { } else {
usage(argv[0]); usage(argv[0]);
} }
} else if (strcmp(&argv[i][1], "-fontsize") == 0) { } else if (strcmp(&argv[i][1], "-fontsize") == 0) {
if (i+1<argc) { if (i+1 < argc) {
fontsize=strtol(argv[++i], NULL, 10); fontsize = strtol(argv[++i], NULL, 10);
} else {
usage(argv[0]);
}
} else if (strcmp(&argv[i][1], "-force-tape-width") == 0) {
if (forced_print_width && save_png) {
++i;
continue;
} else { } else {
usage(argv[0]); usage(argv[0]);
} }
} else if (strcmp(&argv[i][1], "-writepng") == 0) { } else if (strcmp(&argv[i][1], "-writepng") == 0) {
if (i+1<argc) { i++;
save_png=argv[++i]; continue;
} else {
usage(argv[0]);
}
} else if (strcmp(&argv[i][1], "-info") == 0) { } 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 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("media width = %d mm\n", ptdev->status->media_width);
printf("tape color = %02x\n", ptdev->status->tape_color); printf("tape color = %02x (%s)\n", ptdev->status->tape_color, pt_tapecolor(ptdev->status->tape_color));
printf("text color = %02x\n", ptdev->status->text_color); printf("text color = %02x (%s)\n", ptdev->status->text_color, pt_textcolor(ptdev->status->text_color));
printf("error = %04x\n", ptdev->status->error); printf("error = %04x\n", ptdev->status->error);
if (debug) {
ptouch_rawstatus((uint8_t *)ptdev->status);
}
exit(0); exit(0);
} else if (strcmp(&argv[i][1], "-image") == 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")); printf(_("failed to load image file\n"));
return 1; return 1;
} }
out=img_append(out, im); out = img_append(out, im);
gdImageDestroy(im); gdImageDestroy(im);
im = NULL; im = NULL;
} else if (strcmp(&argv[i][1], "-text") == 0) { } 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] == '-')) { if ((i+1 >= argc) || (argv[i+1][0] == '-')) {
break; break;
} }
i++; ++i;
line[lines]=argv[i]; line[lines] = argv[i];
} }
if (lines) { 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")); printf(_("could not render text\n"));
return 1; return 1;
} }
out=img_append(out, im); out = img_append(out, im);
gdImageDestroy(im); gdImageDestroy(im);
im = NULL; im = NULL;
} }
} else if (strcmp(&argv[i][1], "-cutmark") == 0) { } else if (strcmp(&argv[i][1], "-cutmark") == 0) {
im=img_cutmark(tape_width); im = img_cutmark(print_width);
out=img_append(out, im); out = img_append(out, im);
gdImageDestroy(im); gdImageDestroy(im);
im = NULL; im = NULL;
} else if (strcmp(&argv[i][1], "-pad") == 0) { } else if (strcmp(&argv[i][1], "-pad") == 0) {
int length=strtol(argv[++i], NULL, 10); int length=strtol(argv[++i], NULL, 10);
im=img_padding(tape_width, length); im = img_padding(print_width, length);
out=img_append(out, im); out = img_append(out, im);
gdImageDestroy(im); gdImageDestroy(im);
im = NULL; im = NULL;
} else if (strcmp(&argv[i][1], "-chain") == 0) {
chain = true;
} else if (strcmp(&argv[i][1], "-debug") == 0) { } else if (strcmp(&argv[i][1], "-debug") == 0) {
debug = true; debug = true;
} else if (strcmp(&argv[i][1], "-copies") == 0) {
copies = strtol(argv[++i], NULL, 10);
} else { } else {
usage(argv[0]); usage(argv[0]);
} }
@ -563,10 +650,12 @@ int main(int argc, char *argv[])
if (save_png) { if (save_png) {
write_png(out, save_png); write_png(out, save_png);
} else { } else {
print_img(ptdev, out); for (i = 0; i < copies; ++i) {
if (ptouch_eject(ptdev) != 0) { print_img(ptdev, out, chain);
printf(_("ptouch_eject() failed\n")); if (ptouch_finalize(ptdev, ( chain || (i < copies-1) ) ) != 0) {
return -1; printf(_("ptouch_finalize(%d) failed\n"), chain);
return 2;
}
} }
} }
gdImageDestroy(out); gdImageDestroy(out);
@ -574,7 +663,9 @@ int main(int argc, char *argv[])
if (im != NULL) { if (im != NULL) {
gdImageDestroy(im); gdImageDestroy(im);
} }
ptouch_close(ptdev); if (!forced_print_width) {
ptouch_close(ptdev);
}
libusb_exit(NULL); libusb_exit(NULL);
return 0; return 0;
} }

View File

@ -0,0 +1,19 @@
# 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"
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"