Compare commits

..

No commits in common. "master" and "v1.6" have entirely different histories.
master ... v1.6

14 changed files with 755 additions and 1007 deletions

View file

@ -14,7 +14,6 @@ find_package(GD REQUIRED)
find_package(Git REQUIRED) find_package(Git REQUIRED)
find_package(PkgConfig REQUIRED) find_package(PkgConfig REQUIRED)
find_package(Intl REQUIRED) find_package(Intl REQUIRED)
find_package(argp REQUIRED)
pkg_check_modules(LIBUSB REQUIRED libusb-1.0) pkg_check_modules(LIBUSB REQUIRED libusb-1.0)
@ -27,7 +26,6 @@ target_include_directories(${PROJECT_NAME} PUBLIC
${GD_INCLUDE_DIR} ${GD_INCLUDE_DIR}
${LIBUSB_INCLUDE_DIRS} ${LIBUSB_INCLUDE_DIRS}
${Intl_INCLUDE_DIRS} ${Intl_INCLUDE_DIRS}
${ARGP_INCLUDE_DIR}
) )
target_link_libraries(${PROJECT_NAME} PRIVATE target_link_libraries(${PROJECT_NAME} PRIVATE
@ -35,11 +33,11 @@ target_link_libraries(${PROJECT_NAME} PRIVATE
${LIBUSB_LIBRARIES} ${LIBUSB_LIBRARIES}
${LIBUSB_LINK_LIBRARIES} ${LIBUSB_LINK_LIBRARIES}
${Intl_LIBRARIES} ${Intl_LIBRARIES}
${ARGP_LIBRARIES}
) )
target_sources(${PROJECT_NAME} PRIVATE target_sources(${PROJECT_NAME} PRIVATE
include/ptouch.h include/ptouch.h
include/gettext.h
src/libptouch.c src/libptouch.c
src/ptouch-print.c src/ptouch-print.c
) )
@ -68,13 +66,11 @@ add_custom_target(git-version ALL
${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/gitversion.cmake ${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(TARGETS ${PROJECT_NAME} DESTINATION bin)
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)
if(EXISTS /etc/udev/rules.d) if(EXISTS /etc/udev/rules.d)
install(FILES udev/20-usb-ptouch-permissions.rules DESTINATION /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)") install(CODE "execute_process(COMMAND udevadm control --reload-rules)")
endif() endif()

2
README
View file

@ -16,7 +16,7 @@ https://dominic.familie-radermacher.ch/projekte/ptouch-print/
Compile instructions: Compile instructions:
./compile.sh ./build.sh
Note: Note:

View file

@ -1,86 +0,0 @@
# This file is part of CMake-argp.
#
# CMake-argp is free software: you can redistribute it and/or modify it under
# the terms of the GNU Lesser 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 Lesser General Public License along
# with this program. If not, see
#
# http://www.gnu.org/licenses/
#
#
# Copyright (c)
# 2016-2017 Alexander Haase <ahaase@alexhaase.de>
#
include(CheckFunctionExists)
include(FindPackageHandleStandardArgs)
include(FindPackageMessage)
# Do the following checks for header, library and argp functions quietly. Only
# print the result at the end of this file.
set(CMAKE_REQUIRED_QUIET TRUE)
# First check if argp is shipped together with libc without linking to any other
# library or including any paths. In that case, no files for argp need to be
# searched and argp may be used out-of-the-box.
check_function_exists("argp_parse" ARGP_IN_LIBC)
if (ARGP_IN_LIBC)
# Set the argp library- and include-paths to empty values, otherwise CMake
# might print warnings about unknown variables and fills them with
# 'xy-NOTFOUND'.
set(ARGP_FOUND TRUE)
set(ARGP_LIBRARIES "")
set(ARGP_INCLUDE_PATH "")
# Print a message, that argp has been successfully found and return from
# this module, as argp doesn't need to be searched as a separate library.
find_package_message(argp "Found argp: built-in" "built-in")
return()
endif()
# Argp is not part of the libc, so it needs to be searched as a separate library
# with its own include directory.
#
# First search the argp header file. If it is not found, any further steps will
# fail.
find_path(ARGP_INCLUDE_PATH "argp.h")
if (ARGP_INCLUDE_PATH)
# Try to find the argp library and check if it has the required argp_parse
# function.
set(CMAKE_REQUIRED_INCLUDES "${ARGP_INCLUDE_PATH}")
find_library(ARGP_LIBRARIES "argp")
# Check if argp_parse is available. Some implementations don't have this
# symbol defined, thus they're not compatible.
if (ARGP_LIBRARIES)
set(CMAKE_REQUIRED_LIBRARIES "${ARGP_LIBRARIES}")
check_function_exists("argp_parse" ARGP_EXTERNAL)
if (NOT ARGP_EXTERNAL)
message(FATAL_ERROR "Your system ships an argp library in "
"${ARGP_LIBRARIES}, but it does not have a symbol "
"named argp_parse.")
endif ()
endif ()
endif ()
# Restore the quiet settings. By default the last check should be printed if not
# disabled in the find_package call.
set(CMAKE_REQUIRED_QUIET ${argp_FIND_QUIETLY})
# Check for all required variables.
find_package_handle_standard_args(argp
DEFAULT_MSG
ARGP_LIBRARIES ARGP_INCLUDE_PATH)
mark_as_advanced(ARGP_LIBRARIES ARGP_INCLUDE_PATH)

View file

@ -1,72 +0,0 @@
# Utilize gettext multilingual internationalization services
if(Gettext_FOUND)
# 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)
add_custom_command(
TARGET pot-update
PRE_BUILD
COMMAND ${GETTEXT_XGETTEXT_EXECUTABLE}
--keyword=_
--keyword=N_
--force-po
--package-name=${PROJECT_NAME}
--copyright-holder="Dominic Radermacher <dominic@familie-radermacher.ch>"
--msgid-bugs-address="dominic@familie-radermacher.ch"
--output ${CMAKE_SOURCE_DIR}/po/ptouch.pot
${C_FILES}
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)
# read available languages from LINGUAS file while ignoring comments
file(STRINGS po/LINGUAS LINGUAS REGEX "^[^#]")
# 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
)
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
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()

288
include/gettext.h Normal file
View file

@ -0,0 +1,288 @@
/* Convenience header for conditional use of GNU <libintl.h>.
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 <http://www.gnu.org/licenses/>. */
#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 <libintl.h>
/* 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 <locale.h> a NOP. We don't include <libintl.h>
as well because people using "gettext.h" will not include <libintl.h>,
and also including <libintl.h> would fail on SunOS 4, whereas <locale.h>
is OK. */
#if defined(__sun)
# include <locale.h>
#endif
/* Many header files from the libstdc++ coming with g++ 3.3 or newer include
<libintl.h>, which chokes if dcgettext is defined as a macro. So include
it now, to make later inclusions of <libintl.h> a NOP. */
#if defined(__cplusplus) && defined(__GNUG__) && (__GNUC__ >= 3)
# include <cstdlib>
# if (__GLIBC__ >= 2 && !defined __UCLIBC__) || _GLIBCXX_HAVE_LIBINTL_H
# include <libintl.h>
# 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 <string.h>
#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 <stdlib.h>
#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 */

View file

@ -106,7 +106,7 @@ 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_finalize(ptouch_dev ptdev, int chain); int ptouch_finalize(ptouch_dev ptdev, int chain);
int ptouch_getstatus(ptouch_dev ptdev, int timeout); 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_magic(ptouch_dev ptdev);
int ptouch_send_d460bt_chain(ptouch_dev ptdev); int ptouch_send_d460bt_chain(ptouch_dev ptdev);

175
po/de.po
View file

@ -8,7 +8,7 @@ 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: 2025-12-08 15:27+0100\n" "POT-Creation-Date: 2024-05-23 22:20-0400\n"
"PO-Revision-Date: 2024-05-23 22:27-0400\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"
@ -19,293 +19,218 @@ msgstr ""
"Plural-Forms: nplurals=2; plural=(n != 1);\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Generator: Poedit 2.4.2\n" "X-Generator: Poedit 2.4.2\n"
#: src/libptouch.c:107 src/libptouch.c:111 src/libptouch.c:115 #: 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:119 #: 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:128 #: 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:134 #: 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:149 #: 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:155 #: 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:159 #: 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:170 #: 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:190 #: src/libptouch.c:178
#, c-format
msgid "debug: called ptouch_send() with NULL ptdev\n"
msgstr ""
#: src/libptouch.c:197
#, c-format #, c-format
msgid "write error: %s\n" msgid "write error: %s\n"
msgstr "" msgstr ""
#: src/libptouch.c:201 #: src/libptouch.c:182
#, fuzzy, c-format #, fuzzy, c-format
#| msgid "read error: got %i instead of 32 bytes\n"
msgid "write error: could send only %i of %ld bytes\n" msgid "write error: could send only %i of %ld bytes\n"
msgstr "Lesefehler: %i anstatt 32 bytes empfangen\n" msgstr "Lesefehler: %i anstatt 32 bytes empfangen\n"
#: src/libptouch.c:251 #: src/libptouch.c:302
#, c-format
msgid "debug: called ptouch_info_cmd() with NULL ptdev\n"
msgstr ""
#: src/libptouch.c:293
#, fuzzy, c-format
msgid "debug: called ptouch_rasterstart() with NULL ptdev\n"
msgstr "ptouch_rasterstart() fehlgeschlagen\n"
#: src/libptouch.c:324
#, c-format
msgid "debug: called ptouch_finalize() with NULL ptdev\n"
msgstr ""
#: src/libptouch.c:339
#, c-format #, c-format
msgid "debug: dumping raw status bytes\n" msgid "debug: dumping raw status bytes\n"
msgstr "" msgstr ""
#: src/libptouch.c:358 #: src/libptouch.c:326 src/libptouch.c:362
#, c-format
msgid "debug: called ptouch_getstatus() with NULL ptdev\n"
msgstr ""
#: src/libptouch.c:368 src/libptouch.c:404
#, c-format #, c-format
msgid "read error: %s\n" msgid "read error: %s\n"
msgstr "" msgstr ""
#: src/libptouch.c:373 #: src/libptouch.c:331
#, c-format #, c-format
msgid "timeout (%i sec) while waiting for status response\n" msgid "timeout while waiting for status response\n"
msgstr "" msgstr ""
#: src/libptouch.c:387 #: src/libptouch.c:345
#, 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:393 #: 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:397 #: 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:400 #: 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:402 #: 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:407 #: 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/libptouch.c:414 #: src/ptouch-print.c:82
#, c-format
msgid "debug: called ptouch_get_tape_width() with NULL ptdev\n"
msgstr ""
#: src/libptouch.c:423
#, c-format
msgid "debug: called ptouch_get_max_width() with NULL ptdev\n"
msgstr ""
#: src/libptouch.c:435
#, c-format
msgid "debug: called ptouch_sendraster() with NULL ptdev\n"
msgstr ""
#: src/ptouch-print.c:152
#, c-format #, c-format
msgid "nothing to print\n" msgid "nothing to print\n"
msgstr "" msgstr ""
#: src/ptouch-print.c:160 #: 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:161 #: 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:164 #: src/ptouch-print.c:104
#, fuzzy, c-format
msgid "image size (%ipx x %ipx)\n"
msgstr "Bild ist zu gross (%ipx x %ipx)\n"
#: src/ptouch-print.c:174
#, 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:180 #: src/ptouch-print.c:110
#, c-format #, c-format
msgid "send print information command\n" msgid "send print information command\n"
msgstr "" msgstr ""
#: src/ptouch-print.c:186 #: src/ptouch-print.c:116
#, c-format #, c-format
msgid "send PT-D460BT magic commands\n" msgid "send PT-D460BT magic commands\n"
msgstr "" msgstr ""
#: src/ptouch-print.c:193 #: src/ptouch-print.c:122
#, c-format #, c-format
msgid "send precut command\n" msgid "send precut command\n"
msgstr "" msgstr ""
#: src/ptouch-print.c:202 #: src/ptouch-print.c:133
#, c-format
msgid "send PT-D460BT chain commands\n"
msgstr ""
#: src/ptouch-print.c:214
#, fuzzy, c-format #, fuzzy, c-format
#| msgid "ptouch_send() failed\n"
msgid "ptouch_sendraster() failed\n" msgid "ptouch_sendraster() failed\n"
msgstr "ptouch_send() fehlgeschlagen\n" msgstr "ptouch_send() fehlgeschlagen\n"
#: src/ptouch-print.c:263 #: 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:285 #: src/ptouch-print.c:206
#, c-format #, c-format
msgid "debug: o baseline offset - %d\n" msgid "debug: o baseline offset - %d\n"
msgstr "" msgstr ""
#: src/ptouch-print.c:286 #: src/ptouch-print.c:207
#, c-format #, c-format
msgid "debug: text baseline offset - %d\n" msgid "debug: text baseline offset - %d\n"
msgstr "" msgstr ""
#: src/ptouch-print.c:345 #: src/ptouch-print.c:266
#, c-format #, c-format
msgid "render_text(): %i lines, font = '%s', align = '%c'\n" msgid "render_text(): %i lines, font = '%s'\n"
msgstr "" msgstr ""
#: src/ptouch-print.c:348 #: 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:352 #: 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:356 #: 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:363 #: 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:379 src/ptouch-print.c:413 #: 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:593 #: src/ptouch-print.c:495
#, c-format #, c-format
msgid "Only up to %d lines are supported" msgid "ptouch-print version %s by Dominic Radermacher\n"
msgstr "" msgstr "ptouch-print Version %s von Dominic Radermacher\n"
#: src/ptouch-print.c:606 #: src/ptouch-print.c:526
msgid "No arguments supported"
msgstr ""
#: src/ptouch-print.c:611
msgid "Option --writepng missing"
msgstr ""
#: src/ptouch-print.c:614
msgid "Options --force_tape_width and --info can't be used together"
msgstr ""
#: src/ptouch-print.c:645
#, 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:648 #: 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:662 #: src/ptouch-print.c:568
#, 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:663
#, 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:688
#, c-format #, c-format
msgid "failed to load image file\n" msgid "failed to load image file\n"
msgstr "" msgstr ""
#: src/ptouch-print.c:697 #: 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:736 #: src/ptouch-print.c:616
#, c-format #, c-format
msgid "ptouch_finalize(%d) failed\n" msgid "ptouch_finalize(%d) failed\n"
msgstr "ptouch_finalize(%d) fehlgeschlagen\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 #, c-format
#~ msgid "Error 1 = %02x\n" #~ msgid "Error 1 = %02x\n"
#~ msgstr "Fehlerbyte1 = %02x\n" #~ msgstr "Fehlerbyte1 = %02x\n"

179
po/en.po
View file

@ -7,7 +7,7 @@ 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: 2025-12-08 15:27+0100\n" "POT-Creation-Date: 2024-05-23 22:20-0400\n"
"PO-Revision-Date: 2024-05-23 22:26-0400\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"
@ -18,294 +18,217 @@ msgstr ""
"Plural-Forms: nplurals=2; plural=(n != 1);\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Generator: Poedit 2.4.2\n" "X-Generator: Poedit 2.4.2\n"
#: src/libptouch.c:107 src/libptouch.c:111 src/libptouch.c:115 #: 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:119 #: 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:128 #: 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:134 #: 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:149 #: 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:155 #: 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:159 #: 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:170 #: 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:190 #: src/libptouch.c:178
#, c-format
msgid "debug: called ptouch_send() with NULL ptdev\n"
msgstr ""
#: src/libptouch.c:197
#, 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:201 #: src/libptouch.c:182
#, fuzzy, c-format #, 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" 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:251 #: src/libptouch.c:302
#, c-format
msgid "debug: called ptouch_info_cmd() with NULL ptdev\n"
msgstr ""
#: src/libptouch.c:293
#, fuzzy, c-format
msgid "debug: called ptouch_rasterstart() with NULL ptdev\n"
msgstr "ptouch_rasterstart() failed\n"
#: src/libptouch.c:324
#, c-format
msgid "debug: called ptouch_finalize() with NULL ptdev\n"
msgstr ""
#: src/libptouch.c:339
#, 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:358 #: src/libptouch.c:326 src/libptouch.c:362
#, c-format
msgid "debug: called ptouch_getstatus() with NULL ptdev\n"
msgstr ""
#: src/libptouch.c:368 src/libptouch.c:404
#, 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:373 #: src/libptouch.c:331
#, fuzzy, c-format #, c-format
msgid "timeout (%i sec) 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:387 #: src/libptouch.c:345
#, 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:393 #: 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:397 #: 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:400 #: 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:402 #: 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:407 #: 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/libptouch.c:414 #: src/ptouch-print.c:82
#, c-format
msgid "debug: called ptouch_get_tape_width() with NULL ptdev\n"
msgstr ""
#: src/libptouch.c:423
#, c-format
msgid "debug: called ptouch_get_max_width() with NULL ptdev\n"
msgstr ""
#: src/libptouch.c:435
#, c-format
msgid "debug: called ptouch_sendraster() with NULL ptdev\n"
msgstr ""
#: src/ptouch-print.c:152
#, c-format #, c-format
msgid "nothing to print\n" msgid "nothing to print\n"
msgstr "" msgstr ""
#: src/ptouch-print.c:160 #: 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:161 #: 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:164 #: src/ptouch-print.c:104
#, fuzzy, c-format
msgid "image size (%ipx x %ipx)\n"
msgstr "image is too large (%ipx x %ipx)\n"
#: src/ptouch-print.c:174
#, 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:180 #: src/ptouch-print.c:110
#, c-format #, c-format
msgid "send print information command\n" msgid "send print information command\n"
msgstr "" msgstr ""
#: src/ptouch-print.c:186 #: src/ptouch-print.c:116
#, c-format #, c-format
msgid "send PT-D460BT magic commands\n" msgid "send PT-D460BT magic commands\n"
msgstr "" msgstr ""
#: src/ptouch-print.c:193 #: src/ptouch-print.c:122
#, c-format #, c-format
msgid "send precut command\n" msgid "send precut command\n"
msgstr "" msgstr ""
#: src/ptouch-print.c:202 #: src/ptouch-print.c:133
#, c-format
msgid "send PT-D460BT chain commands\n"
msgstr ""
#: src/ptouch-print.c:214
#, c-format #, c-format
msgid "ptouch_sendraster() failed\n" msgid "ptouch_sendraster() failed\n"
msgstr "ptouch_sendraster() failed\n" msgstr "ptouch_sendraster() failed\n"
#: src/ptouch-print.c:263 #: 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:285 #: src/ptouch-print.c:206
#, c-format #, c-format
msgid "debug: o baseline offset - %d\n" msgid "debug: o baseline offset - %d\n"
msgstr "" msgstr ""
#: src/ptouch-print.c:286 #: src/ptouch-print.c:207
#, c-format #, c-format
msgid "debug: text baseline offset - %d\n" msgid "debug: text baseline offset - %d\n"
msgstr "" msgstr ""
#: src/ptouch-print.c:345 #: src/ptouch-print.c:266
#, c-format #, c-format
msgid "render_text(): %i lines, font = '%s', align = '%c'\n" msgid "render_text(): %i lines, font = '%s'\n"
msgstr "" msgstr ""
#: src/ptouch-print.c:348 #: 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:352 #: 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:356 #: 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:363 #: 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:379 src/ptouch-print.c:413 #: 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:593 #: src/ptouch-print.c:495
#, c-format #, c-format
msgid "Only up to %d lines are supported" msgid "ptouch-print version %s by Dominic Radermacher\n"
msgstr "" msgstr "ptouch-print version %s by Dominic Radermacher\n"
#: src/ptouch-print.c:606 #: src/ptouch-print.c:526
msgid "No arguments supported"
msgstr ""
#: src/ptouch-print.c:611
msgid "Option --writepng missing"
msgstr ""
#: src/ptouch-print.c:614
msgid "Options --force_tape_width and --info can't be used together"
msgstr ""
#: src/ptouch-print.c:645
#, 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:648 #: 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:662 #: src/ptouch-print.c:568
#, 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:663
#, 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:688
#, c-format #, c-format
msgid "failed to load image file\n" msgid "failed to load image file\n"
msgstr "" msgstr ""
#: src/ptouch-print.c:697 #: 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:736 #: src/ptouch-print.c:616
#, c-format #, c-format
msgid "ptouch_finalize(%d) failed\n" msgid "ptouch_finalize(%d) failed\n"
msgstr "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 #, c-format
#~ msgid "Error 1 = %02x\n" #~ msgid "Error 1 = %02x\n"
#~ msgstr "Error 1 = %02x\n" #~ msgstr "Error 1 = %02x\n"

View file

@ -1,14 +1,14 @@
# SOME DESCRIPTIVE TITLE. # SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR Dominic\ Radermacher\ <dominic@familie-radermacher.ch> # Copyright (C) YEAR Free Software Foundation, Inc.
# This file is distributed under the same license as the ptouch-print package. # This file is distributed under the same license as the ptouch package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR. # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
# #
#, fuzzy #, fuzzy
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: ptouch-print\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: 2025-12-08 15:31+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,285 +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:107 src/libptouch.c:111 src/libptouch.c:115 #: 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:119 #: src/libptouch.c:107
#, c-format #, c-format
msgid "libusb_init() failed\n" msgid "libusb_init() failed\n"
msgstr "" msgstr ""
#: src/libptouch.c:128 #: 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:134 #: 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:149 #: 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:155 #: 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:159 #: 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:170 #: 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:190 #: src/libptouch.c:178
#, c-format
msgid "debug: called ptouch_send() with NULL ptdev\n"
msgstr ""
#: src/libptouch.c:197
#, c-format #, c-format
msgid "write error: %s\n" msgid "write error: %s\n"
msgstr "" msgstr ""
#: src/libptouch.c:201 #: src/libptouch.c:182
#, c-format #, c-format
msgid "write error: could send only %i of %ld bytes\n" msgid "write error: could send only %i of %ld bytes\n"
msgstr "" msgstr ""
#: src/libptouch.c:251 #: src/libptouch.c:302
#, c-format
msgid "debug: called ptouch_info_cmd() with NULL ptdev\n"
msgstr ""
#: src/libptouch.c:293
#, c-format
msgid "debug: called ptouch_rasterstart() with NULL ptdev\n"
msgstr ""
#: src/libptouch.c:324
#, c-format
msgid "debug: called ptouch_finalize() with NULL ptdev\n"
msgstr ""
#: src/libptouch.c:339
#, c-format #, c-format
msgid "debug: dumping raw status bytes\n" msgid "debug: dumping raw status bytes\n"
msgstr "" msgstr ""
#: src/libptouch.c:358 #: src/libptouch.c:326 src/libptouch.c:362
#, c-format
msgid "debug: called ptouch_getstatus() with NULL ptdev\n"
msgstr ""
#: src/libptouch.c:368 src/libptouch.c:404
#, c-format #, c-format
msgid "read error: %s\n" msgid "read error: %s\n"
msgstr "" msgstr ""
#: src/libptouch.c:373 #: src/libptouch.c:331
#, c-format #, c-format
msgid "timeout (%i sec) while waiting for status response\n" msgid "timeout while waiting for status response\n"
msgstr "" msgstr ""
#: src/libptouch.c:387 #: src/libptouch.c:345
#, 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:393 #: 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:397 #: 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:400 #: src/libptouch.c:358
#, c-format #, c-format
msgid "strange status:\n" msgid "strange status:\n"
msgstr "" msgstr ""
#: src/libptouch.c:402 #: 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:407 #: 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/libptouch.c:414 #: src/ptouch-print.c:82
#, c-format
msgid "debug: called ptouch_get_tape_width() with NULL ptdev\n"
msgstr ""
#: src/libptouch.c:423
#, c-format
msgid "debug: called ptouch_get_max_width() with NULL ptdev\n"
msgstr ""
#: src/libptouch.c:435
#, c-format
msgid "debug: called ptouch_sendraster() with NULL ptdev\n"
msgstr ""
#: src/ptouch-print.c:152
#, c-format #, c-format
msgid "nothing to print\n" msgid "nothing to print\n"
msgstr "" msgstr ""
#: src/ptouch-print.c:160 #: 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:161 #: 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:164 #: src/ptouch-print.c:104
#, c-format
msgid "image size (%ipx x %ipx)\n"
msgstr ""
#: src/ptouch-print.c:174
#, c-format #, c-format
msgid "ptouch_rasterstart() failed\n" msgid "ptouch_rasterstart() failed\n"
msgstr "" msgstr ""
#: src/ptouch-print.c:180 #: src/ptouch-print.c:110
#, c-format #, c-format
msgid "send print information command\n" msgid "send print information command\n"
msgstr "" msgstr ""
#: src/ptouch-print.c:186 #: src/ptouch-print.c:116
#, c-format #, c-format
msgid "send PT-D460BT magic commands\n" msgid "send PT-D460BT magic commands\n"
msgstr "" msgstr ""
#: src/ptouch-print.c:193 #: src/ptouch-print.c:122
#, c-format #, c-format
msgid "send precut command\n" msgid "send precut command\n"
msgstr "" msgstr ""
#: src/ptouch-print.c:202 #: src/ptouch-print.c:133
#, c-format
msgid "send PT-D460BT chain commands\n"
msgstr ""
#: src/ptouch-print.c:214
#, c-format #, c-format
msgid "ptouch_sendraster() failed\n" msgid "ptouch_sendraster() failed\n"
msgstr "" msgstr ""
#: src/ptouch-print.c:263 #: 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:285 #: src/ptouch-print.c:206
#, c-format #, c-format
msgid "debug: o baseline offset - %d\n" msgid "debug: o baseline offset - %d\n"
msgstr "" msgstr ""
#: src/ptouch-print.c:286 #: src/ptouch-print.c:207
#, c-format #, c-format
msgid "debug: text baseline offset - %d\n" msgid "debug: text baseline offset - %d\n"
msgstr "" msgstr ""
#: src/ptouch-print.c:345 #: src/ptouch-print.c:266
#, c-format #, c-format
msgid "render_text(): %i lines, font = '%s', align = '%c'\n" msgid "render_text(): %i lines, font = '%s'\n"
msgstr "" msgstr ""
#: src/ptouch-print.c:348 #: 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:352 #: 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:356 #: 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:363 #: 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:379 src/ptouch-print.c:413 #: 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:593 #: src/ptouch-print.c:495
#, c-format #, c-format
msgid "Only up to %d lines are supported" msgid "ptouch-print version %s by Dominic Radermacher\n"
msgstr "" msgstr ""
#: src/ptouch-print.c:606 #: src/ptouch-print.c:526
msgid "No arguments supported"
msgstr ""
#: src/ptouch-print.c:611
msgid "Option --writepng missing"
msgstr ""
#: src/ptouch-print.c:614
msgid "Options --force_tape_width and --info can't be used together"
msgstr ""
#: src/ptouch-print.c:645
#, c-format #, c-format
msgid "ptouch_init() failed\n" msgid "ptouch_init() failed\n"
msgstr "" msgstr ""
#: src/ptouch-print.c:648 #: 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:662 #: src/ptouch-print.c:568
#, c-format
msgid "maximum printing width for this printer is %ldpx\n"
msgstr ""
#: src/ptouch-print.c:663
#, c-format
msgid "maximum printing width for this tape is %ldpx\n"
msgstr ""
#: src/ptouch-print.c:688
#, c-format #, c-format
msgid "failed to load image file\n" msgid "failed to load image file\n"
msgstr "" msgstr ""
#: src/ptouch-print.c:697 #: 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:736 #: src/ptouch-print.c:616
#, c-format #, c-format
msgid "ptouch_finalize(%d) failed\n" msgid "ptouch_finalize(%d) failed\n"
msgstr "" msgstr ""

View file

@ -28,12 +28,6 @@ once in any order, and will be executed in the given order.
.TP .TP
.BR \-\-debug .BR \-\-debug
Enables printing of debugging information. Enables printing of debugging information.
.TP
.BR \-\-timeout\ \fI<time>
Set the seconds ptouch-print is waiting for finishing a previous ptouch-print command.
Default is 1 second. 0 (zero) means wait forever.
Useful if ptouch-print is used in a script multiple times, and the device is waiting for the user
to use the mechanical cutter.
.SS "Font selection options" .SS "Font selection options"
.TP .TP

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-2025 Dominic Radermacher <dominic@familie-radermacher.ch> Copyright (C) 2013-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
@ -26,31 +26,28 @@
#include <sys/stat.h> /* open() */ #include <sys/stat.h> /* open() */
#include <fcntl.h> /* open() */ #include <fcntl.h> /* open() */
#include <time.h> /* nanosleep(), struct timespec */ #include <time.h> /* nanosleep(), struct timespec */
#include <libintl.h> /* gettext() */
#include "gettext.h" /* gettext(), ngettext() */
#include "ptouch.h" #include "ptouch.h"
#define _(s) gettext(s) #define _(s) gettext(s)
/* Print area width in 180 DPI pixels */ /* Print area width in 180 DPI pixels */
struct _pt_tape_info tape_info[]= { struct _pt_tape_info tape_info[]= {
{ 4, 24, 0.5}, /* 3.5 mm tape */ { 4, 24, 0.5}, /* 3.5 mm tape */
{ 6, 32, 1.0}, /* 6 mm tape */ { 6, 32, 1.0}, /* 6 mm tape */
{ 9, 52, 1.0}, /* 9 mm tape */ { 9, 52, 1.0}, /* 9 mm tape */
{12, 76, 2.0}, /* 12 mm tape */ {12, 76, 2.0}, /* 12 mm tape */
{18, 120, 3.0}, /* 18 mm tape */ {18, 120, 3.0}, /* 18 mm tape */
{21, 124, 3.0}, /* 21 mm tape */
{24, 128, 3.0}, /* 24 mm tape */ {24, 128, 3.0}, /* 24 mm tape */
{36, 192, 4.5}, /* 36 mm tape */ {36, 192, 4.5}, /* 36 mm tape */
{ 0, 0, 0.0} /* terminating entry */ { 0, 0, 0.0} /* terminating entry */
}; };
struct _pt_dev_info ptdevs[] = { 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, 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", 112, 180, FLAG_RASTER_PACKBITS}, /* 180dpi, apparently 112px printhead ?, maximum tape width 18mm - unconfirmed if it works */ {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_HAS_PRECUT}, {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
@ -62,15 +59,12 @@ struct _pt_dev_info ptdevs[] = {
{0x04f9, 0x2041, "PT-2730", 128, 180, FLAG_NONE}, /* 180dpi, maximum 128px, max tape width 24mm - reported to work with some quirks */ {0x04f9, 0x2041, "PT-2730", 128, 180, FLAG_NONE}, /* 180dpi, maximum 128px, max tape width 24mm - reported to work with some quirks */
/* Notes about the PT-2730: was reported to need 48px whitespace /* Notes about the PT-2730: was reported to need 48px whitespace
within png-images before content is actually printed - can not check this */ within png-images before content is actually printed - can not check this */
{0x04f9, 0x205e, "PT-H500", 128, 180, FLAG_RASTER_PACKBITS|FLAG_HAS_PRECUT}, {0x04f9, 0x205e, "PT-H500", 128, 180, FLAG_RASTER_PACKBITS},
/* Note about the PT-H500: was reported by Eike with the remark that /* Note about the PT-H500: was reported by Eike with the remark that
it might need some trailing padding */ it might need some trailing padding */
{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, 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, 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},
@ -85,12 +79,6 @@ 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, 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|FLAG_HAS_PRECUT}, {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},
{0x04f9, 0x2203, "PT-E560BT", 128, 180, FLAG_P700_INIT|FLAG_USE_INFO_CMD|FLAG_D460BT_MAGIC},
{0,0,"",0,0,0} {0,0,"",0,0,0}
}; };
@ -174,9 +162,6 @@ int ptouch_open(ptouch_dev *ptdev)
int ptouch_close(ptouch_dev ptdev) int ptouch_close(ptouch_dev ptdev)
{ {
if (!ptdev) {
return -1;
}
libusb_release_interface(ptdev->h, 0); libusb_release_interface(ptdev->h, 0);
libusb_close(ptdev->h); libusb_close(ptdev->h);
return 0; return 0;
@ -186,11 +171,7 @@ int ptouch_send(ptouch_dev ptdev, uint8_t *data, size_t len)
{ {
int r, tx; int r, tx;
if (!ptdev) { if ((ptdev == NULL) || (len > 128)) {
fprintf(stderr, _("debug: called ptouch_send() with NULL ptdev\n"));
return -1;
}
if (len > 128) {
return -1; return -1;
} }
if ((r=libusb_bulk_transfer(ptdev->h, 0x02, data, (int)len, &tx, 0)) != 0) { if ((r=libusb_bulk_transfer(ptdev->h, 0x02, data, (int)len, &tx, 0)) != 0) {
@ -230,11 +211,10 @@ int ptouch_send_d460bt_magic(ptouch_dev ptdev)
uint8_t cmd[7]; uint8_t cmd[7];
/* n1 and n2 are the length margin/spacing, in px? (uint16_t value, little endian) */ /* 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 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 */ /* The default for P-Touch software is 0x0e */
/* n3 must be 0x4D or the print gets corrupted! */ /* n3 must be 0x4D or the print gets corrupted! */
/* n4 seems to be ignored or reserved. */ /* n4 seems to be ignored or reserved. */
memcpy(cmd, "\x1b\x69\x64\x01\x00\x4d\x00", 7); memcpy(cmd, "\x1b\x69\x64\x0e\x00\x4d\x00", 7);
return ptouch_send(ptdev, (uint8_t *)cmd, sizeof(cmd)); return ptouch_send(ptdev, (uint8_t *)cmd, sizeof(cmd));
} }
@ -247,11 +227,6 @@ int ptouch_enable_packbits(ptouch_dev ptdev)
/* print information command */ /* print information command */
int ptouch_info_cmd(ptouch_dev ptdev, int size_x) 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} */ /* 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"; uint8_t cmd[] = "\x1b\x69\x7a\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00";
@ -289,10 +264,6 @@ int ptouch_send_precut_cmd(ptouch_dev ptdev, int precut)
int ptouch_rasterstart(ptouch_dev ptdev) 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 */ /* 1B 69 52 01 = Select graphics transfer mode = Raster */
char cmd[] = "\x1b\x69\x52\x01"; char cmd[] = "\x1b\x69\x52\x01";
/* 1B 69 61 01 = switch mode (0=esc/p, 1=raster mode) */ /* 1B 69 61 01 = switch mode (0=esc/p, 1=raster mode) */
@ -320,11 +291,6 @@ int ptouch_ff(ptouch_dev ptdev)
/* finish print and either cut or leave tape in machine */ /* finish print and either cut or leave tape in machine */
int ptouch_finalize(ptouch_dev ptdev, int chain) 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_eject[]="\x1a"; /* Print command with feeding */
char cmd_chain[]="\x0c"; /* Print command (no cut) */ char cmd_chain[]="\x0c"; /* Print command (no cut) */
@ -338,7 +304,7 @@ 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, "0x%02x ", raw[i]); fprintf(stderr, "%02x ", raw[i]);
if (((i+1) % 16) == 0) { if (((i+1) % 16) == 0) {
fprintf(stderr, "\n"); fprintf(stderr, "\n");
} }
@ -347,18 +313,13 @@ void ptouch_rawstatus(uint8_t raw[32])
return; return;
} }
int ptouch_getstatus(ptouch_dev ptdev, int timeout) 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, maxtries=timeout*10; int i, r, tx=0, tries=0;
struct timespec w; 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)); ptouch_send(ptdev, (uint8_t *)cmd, strlen(cmd));
while (tx == 0) { while (tx == 0) {
w.tv_sec=0; w.tv_sec=0;
@ -369,8 +330,8 @@ int ptouch_getstatus(ptouch_dev ptdev, int timeout)
return -1; return -1;
} }
++tries; ++tries;
if (timeout && tries > maxtries) { if (tries > 10) {
fprintf(stderr, _("timeout (%i sec) while waiting for status response\n"), timeout); fprintf(stderr, _("timeout while waiting for status response\n"));
return -1; return -1;
} }
} }
@ -410,19 +371,11 @@ int ptouch_getstatus(ptouch_dev ptdev, int timeout)
size_t ptouch_get_tape_width(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; return ptdev->tape_width_px;
} }
size_t ptouch_get_max_width(ptouch_dev ptdev) 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; return ptdev->devinfo->max_px;
} }
@ -431,10 +384,6 @@ int ptouch_sendraster(ptouch_dev ptdev, uint8_t *data, size_t len)
uint8_t buf[64]; uint8_t buf[64];
int rc; 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)) { if (len > (size_t)(ptdev->devinfo->max_px / 8)) {
return -1; return -1;
} }
@ -457,21 +406,12 @@ int ptouch_sendraster(ptouch_dev ptdev, uint8_t *data, size_t len)
void ptouch_list_supported() void ptouch_list_supported()
{ {
const int columns = 5;
printf("Supported printers (some might have quirks)\n"); printf("Supported printers (some might have quirks)\n");
int col=0;
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("%s", ptdevs[i].name); printf("\t%s\n", ptdevs[i].name);
if (strlen(ptdevs[i].name) < 8) {
printf("\t");
}
printf("%c", (col < (columns - 1))?'\t':'\n');
++col;
col = (col % columns);
} }
} }
printf("\n");
return; return;
} }
@ -482,11 +422,10 @@ const char* pt_mediatype(const uint8_t media_type)
case 0x01: return "Laminated tape"; break; case 0x01: return "Laminated tape"; break;
case 0x03: return "Non-laminated tape"; break; case 0x03: return "Non-laminated tape"; break;
case 0x04: return "Fabric tape"; break; case 0x04: return "Fabric tape"; break;
case 0x11: return "Heat-shrink tube"; break; // Seems wrong, should be 0x17 case 0x11: return "Heat-shrink tube"; break;
case 0x13: return "Flexi tape"; break; case 0x13: return "Fle tape"; break;
case 0x14: return "Flexible ID tape"; break; case 0x14: return "Flexible ID tape"; break;
case 0x15: return "Satin tape"; break; case 0x15: return "Satin tape"; break;
case 0x17: return "Heat-shrink tube"; break;
case 0xff: return "Incompatible tape"; break; case 0xff: return "Incompatible tape"; break;
default: return "unknown"; default: return "unknown";
} }
@ -520,7 +459,6 @@ const char* pt_tapecolor(const uint8_t tape_color)
case 0x61: return "Pink"; break; case 0x61: return "Pink"; break;
case 0x62: return "Blue"; break; case 0x62: return "Blue"; break;
case 0x70: return "Heat-shrink Tube"; break; case 0x70: return "Heat-shrink Tube"; break;
case 0x71: return "Heat-shrink Tube white"; break;
case 0x90: return "White(Flex. ID)"; break; case 0x90: return "White(Flex. ID)"; break;
case 0x91: return "Yellow(Flex. ID)"; break; case 0x91: return "Yellow(Flex. ID)"; break;
case 0xf0: return "Cleaning"; break; case 0xf0: return "Cleaning"; break;

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-2025 Dominic Radermacher <dominic@familie-radermacher.ch> Copyright (C) 2015-2024 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
@ -17,7 +17,6 @@
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#include <argp.h>
#include <stdio.h> /* printf() */ #include <stdio.h> /* printf() */
#include <stdlib.h> /* exit(), malloc() */ #include <stdlib.h> /* exit(), malloc() */
#include <stdbool.h> #include <stdbool.h>
@ -30,105 +29,36 @@
#include <locale.h> /* LC_ALL */ #include <locale.h> /* LC_ALL */
#include "version.h" #include "version.h"
#include "gettext.h" /* gettext(), ngettext() */
#include "ptouch.h" #include "ptouch.h"
#define _(s) gettext(s) #define _(s) gettext(s)
#define MAX_LINES 4 /* maybe this should depend on tape size */ #define MAX_LINES 4 /* maybe this should depend on tape size */
#define P_NAME "ptouch-print"
typedef enum { ALIGN_LEFT = 'l', ALIGN_CENTER = 'c', ALIGN_RIGHT = 'r' } align_type_t;
struct arguments {
align_type_t align;
bool chain;
bool precut;
int copies;
bool debug;
bool info;
char *font_file;
int font_size;
int forced_tape_width;
char *save_png;
int verbose;
int timeout;
};
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); gdImage *image_load(const char *file);
void rasterline_setpixel(uint8_t* rasterline, size_t size, int pixel); 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 chain, int precut); 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 print_width); gdImage *img_cutmark(int tape_width);
gdImage *render_text(char *font, char *line[], int lines, int print_width); gdImage *render_text(char *font, char *line[], int lines, int tape_width);
void unsupported_printer(ptouch_dev ptdev); void unsupported_printer(ptouch_dev ptdev);
void add_job(job_type_t type, int n, char *line); void usage(char *progname);
static error_t parse_opt(int key, char *arg, struct argp_state *state); int parse_args(int argc, char **argv);
const char *argp_program_version = P_NAME " " VERSION; // char *font_file = "/usr/share/fonts/TTF/Ubuntu-M.ttf";
const char *argp_program_bug_address = "Dominic Radermacher <dominic@familie-radermacher.ch>"; // char *font_file = "Ubuntu:medium";
static char doc[] = "ptouch-print is a command line tool to print labels on Brother P-Touch printers on Linux."; char *font_file = "DejaVuSans";
static char args_doc[] = ""; char *save_png = NULL;
int verbose = 0;
static struct argp_option options[] = { int fontsize = 0;
// name, key, arg, flags, doc, group bool debug = false;
{ 0, 0, 0, 0, "options:", 1}, bool chain = false;
{ "debug", 1, 0, 0, "Enable debug output", 1}, int forced_tape_width = 0;
{ "font", 2, "<file>", 0, "Use font <file> or <name>", 1},
{ "fontsize", 3, "<size>", 0, "Manually set font size", 1},
{ "writepng", 4, "<file>", 0, "Instead of printing, write output to png <file>", 1},
{ "force-tape-width", 5, "<px>", 0, "Set tape width in pixels, use together with --writepng without a printer connected", 1},
{ "copies", 6, "<number>", 0, "Sets the number of identical prints", 1},
{ "timeout", 7, "<seconds>", 0, "Set timeout waiting for finishing previous job. Default:1, 0 means infinity", 1},
{ 0, 0, 0, 0, "print commands:", 2},
{ "image", 'i', "<file>", 0, "Print the given image which must be a 2 color (black/white) png", 2},
{ "text", 't', "<text>", 0, "Print line of <text>. 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', "<n>", 0, "Add n pixels padding (blank tape)", 2},
{ "chain", 10, 0, 0, "Skip final feed of label and any automatic cut", 2},
{ "precut", 11, 0, 0, "Add a cut before the label (useful in chain mode for cuts with minimal waste)", 2},
{ "newline", 'n', "<text>", 0, "Add text in a new line (up to 4 lines)", 2},
{ "align", 'a', "<l|c|r>", 0, "Align text (when printing multiple lines)", 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 = {
.align = ALIGN_LEFT,
.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,
.timeout = 1
};
job_t *jobs = NULL;
job_t *last_added_job = NULL;
/* -------------------------------------------------------------------- /* --------------------------------------------------------------------
-------------------------------------------------------------------- */ -------------------------------------------------------------------- */
@ -137,35 +67,36 @@ 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 < 0) || (pixel >= (int)(size*8))) { if (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 chain, int precut) 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;
} }
int tape_width = ptouch_get_tape_width(ptdev); 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 */
int d = (gdImageRed(im,1) + gdImageGreen(im,1) + gdImageBlue(im,1) < gdImageRed(im,0) + gdImageGreen(im,0) + gdImageBlue(im,0))?1:0; 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;
} }
printf(_("image size (%ipx x %ipx)\n"), gdImageSX(im), gdImageSY(im)); //offset=64-(gdImageSY(im)/2); /* always print centered */
int offset = ((int)max_pixels / 2) - (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=%ld, 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 ((ptdev->devinfo->flags & FLAG_RASTER_PACKBITS) == FLAG_RASTER_PACKBITS) {
if (arguments.debug) { if (debug) {
printf("enable PackBits mode\n"); printf("enable PackBits mode\n");
} }
ptouch_enable_packbits(ptdev); ptouch_enable_packbits(ptdev);
@ -176,41 +107,36 @@ int print_img(ptouch_dev ptdev, gdImage *im, int chain, int precut)
} }
if ((ptdev->devinfo->flags & FLAG_USE_INFO_CMD) == FLAG_USE_INFO_CMD) { if ((ptdev->devinfo->flags & FLAG_USE_INFO_CMD) == FLAG_USE_INFO_CMD) {
ptouch_info_cmd(ptdev, gdImageSX(im)); ptouch_info_cmd(ptdev, gdImageSX(im));
if (arguments.debug) { if (debug) {
printf(_("send print information command\n")); printf(_("send print information command\n"));
} }
} }
if ((ptdev->devinfo->flags & FLAG_D460BT_MAGIC) == FLAG_D460BT_MAGIC) { 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); ptouch_send_d460bt_magic(ptdev);
if (arguments.debug) { if (debug) {
printf(_("send PT-D460BT magic commands\n")); printf(_("send PT-D460BT magic commands\n"));
} }
} }
if ((ptdev->devinfo->flags & FLAG_HAS_PRECUT) == FLAG_HAS_PRECUT) { if ((ptdev->devinfo->flags & FLAG_HAS_PRECUT) == FLAG_HAS_PRECUT) {
if (precut) { ptouch_send_precut_cmd(ptdev, 1);
ptouch_send_precut_cmd(ptdev, 1); if (debug) {
if (arguments.debug) { printf(_("send precut command\n"));
printf(_("send precut command\n"));
}
} }
} }
/* send chain command after precut, to allow precutting before chain */ 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 (arguments.debug) {
printf(_("send PT-D460BT chain commands\n"));
}
}
}
for (int k = 0; k < gdImageSX(im); ++k) {
memset(rasterline, 0, sizeof(rasterline)); memset(rasterline, 0, sizeof(rasterline));
for (int i = 0; i < gdImageSY(im); ++i) { for (i=0; i<gdImageSY(im); i+=1) {
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, (ptdev->devinfo->max_px / 8)) != 0) { if (ptouch_sendraster(ptdev, rasterline, 16) != 0) {
printf(_("ptouch_sendraster() failed\n")); printf(_("ptouch_sendraster() failed\n"));
return -1; return -1;
} }
@ -227,10 +153,10 @@ int print_img(ptouch_dev ptdev, gdImage *im, int chain, int precut)
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;
@ -241,14 +167,14 @@ gdImage *image_load(const char *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);
@ -275,13 +201,15 @@ int write_png(gdImage *im, const char *file)
int get_baselineoffset(char *text, char *font, int fsz) int get_baselineoffset(char *text, char *font, int fsz)
{ {
int brect[8]; int brect[8];
int o_offset;
int text_offset;
/* NOTE: This assumes that 'o' is always on the baseline */ /* NOTE: This assumes that 'o' is always on the baseline */
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 o_offset = brect[1]; o_offset=brect[1];
gdImageStringFT(NULL, &brect[0], -1, font, fsz, 0.0, 0, 0, text); gdImageStringFT(NULL, &brect[0], -1, font, fsz, 0.0, 0, 0, text);
int text_offset = brect[1]; text_offset=brect[1];
if (arguments.debug) { if (debug) {
printf(_("debug: o baseline offset - %d\n"), o_offset); printf(_("debug: o baseline offset - %d\n"), o_offset);
printf(_("debug: text baseline offset - %d\n"), text_offset); printf(_("debug: text baseline offset - %d\n"), text_offset);
} }
@ -295,7 +223,7 @@ 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) {
@ -303,7 +231,7 @@ int find_fontsize(int want_px, char *font, char *text)
break; break;
} }
if (brect[1]-brect[5] <= want_px) { if (brect[1]-brect[5] <= want_px) {
save = i; save=i;
} else { } else {
break; break;
} }
@ -334,25 +262,25 @@ int offset_x(char *text, char *font, int fsz)
return -brect[0]; return -brect[0];
} }
gdImage *render_text(char *font, char *line[], int lines, int print_width) gdImage *render_text(char *font, char *line[], int lines, int tape_width)
{ {
int brect[8]; int brect[8];
int i, black, x = 0, tmp = 0, fsz = 0; int i, black, x=0, tmp=0, fsz=0;
char *p; char *p;
gdImage *im = NULL; gdImage *im=NULL;
if (arguments.debug) { if (debug) {
printf(_("render_text(): %i lines, font = '%s', align = '%c'\n"), lines, font, arguments.align); printf(_("render_text(): %i lines, font = '%s'\n"), lines, font);
} }
if (gdFTUseFontConfig(1) != GD_TRUE) { if (gdFTUseFontConfig(1) != GD_TRUE) {
printf(_("warning: font config not available\n")); printf(_("warning: font config not available\n"));
} }
if (arguments.font_size > 0) { if (fontsize > 0) {
fsz = arguments.font_size; 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(print_width/lines, font, line[i])) < 0) { if ((tmp=find_fontsize(tape_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;
} }
@ -362,54 +290,48 @@ gdImage *render_text(char *font, char *line[], int lines, int print_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], arguments.font_file, fsz); tmp=needed_width(line[i], font_file, fsz);
if (tmp > x) { if (tmp > x) {
x = tmp; x=tmp;
} }
} }
im = gdImageCreatePalette(x, print_width); im=gdImageCreatePalette(x, tape_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 (arguments.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) { if ((max_height * lines) > tape_width) {
printf("Font size %d too large for %d lines\n", fsz, lines); printf("Font size %d too large for %d lines\n", fsz, lines);
return NULL; return NULL;
} }
/* calculate unused pixels */ /* calculate unused pixels */
int unused_px = print_width - (max_height * lines); int unused_px = tape_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], arguments.font_file, fsz); int ofs=get_baselineoffset(line[i], font_file, fsz);
//int pos = ((i)*(print_width/(lines)))+(max_height)-ofs-1; //int pos=((i)*(tape_width/(lines)))+(max_height)-ofs-1;
int pos = ((i)*(print_width/(lines)))+(max_height)-ofs; int pos=((i)*(tape_width/(lines)))+(max_height)-ofs;
pos += (unused_px/lines) / 2; pos += (unused_px/lines) / 2;
if (arguments.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);
} }
int off_x = offset_x(line[i], arguments.font_file, fsz); int off_x = offset_x(line[i], font_file, fsz);
int align_ofs = 0; if ((p=gdImageStringFT(im, &brect[0], -black, font, fsz, 0.0, off_x, pos, line[i])) != NULL) {
if (arguments.align == ALIGN_CENTER) {
align_ofs = (x - needed_width(line[i], arguments.font_file, fsz)) / 2;
} else if (arguments.align == ALIGN_RIGHT) {
align_ofs = x - needed_width(line[i], arguments.font_file, fsz);
}
if ((p = gdImageStringFT(im, &brect[0], -black, font, fsz, 0.0, off_x + align_ofs, pos, line[i])) != NULL) {
printf(_("error in gdImageStringFT: %s\n"), p); printf(_("error in gdImageStringFT: %s\n"), p);
} }
} }
@ -418,80 +340,80 @@ gdImage *render_text(char *font, char *line[], int lines, int print_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;
} }
gdImageColorAllocate(out, 255, 255, 255); gdImageColorAllocate(out, 255, 255, 255);
gdImageColorAllocate(out, 0, 0, 0); gdImageColorAllocate(out, 0, 0, 0);
if (arguments.debug) { if (debug) {
printf("debug: created new img with size %d * %d\n", length, width); printf("debug: created new img with size %d * %d\n", length, width);
} }
if (in_1 != NULL) { if (in_1 != NULL) {
gdImageCopy(out, in_1, 0, 0, 0, 0, gdImageSX(in_1), gdImageSY(in_1)); gdImageCopy(out, in_1, 0, 0, 0, 0, gdImageSX(in_1), gdImageSY(in_1));
if (arguments.debug) { if (debug) {
printf("debug: copied part 1\n"); printf("debug: copied part 1\n");
} }
} }
if (in_2 != NULL) { if (in_2 != NULL) {
gdImageCopy(out, in_2, i_1_x, 0, 0, 0, gdImageSX(in_2), gdImageSY(in_2)); gdImageCopy(out, in_2, i_1_x, 0, 0, 0, gdImageSX(in_2), gdImageSY(in_2));
if (arguments.debug) { if (debug) {
printf("copied part 2\n"); printf("copied part 2\n");
} }
} }
return out; return out;
} }
gdImage *img_cutmark(int print_width) gdImage *img_cutmark(int tape_width)
{ {
gdImage *out = NULL; gdImage *out=NULL;
int style_dashed[6]; int style_dashed[6];
out = gdImageCreatePalette(9, print_width); out=gdImageCreatePalette(9, tape_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, print_width - 1, gdStyled); gdImageLine(out, 5, 0, 5, tape_width-1, gdStyled);
return out; return out;
} }
gdImage *img_padding(int print_width, int length) gdImage *img_padding(int tape_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, print_width); out=gdImageCreatePalette(length, tape_width);
if (out == NULL) { if (out == NULL) {
return NULL; return NULL;
} }
@ -499,241 +421,235 @@ gdImage *img_padding(int print_width, int length)
return out; return out;
} }
void add_job(job_type_t type, int n, char *line) void usage(char *progname)
{ {
job_t *new_job = (job_t*)malloc(sizeof(job_t)); printf("usage: %s [options] <print-command(s)>\n", progname);
if (!new_job) { printf("options:\n");
fprintf(stderr, "Memory allocation failed\n"); printf("\t--debug\t\t\tenable debug output\n");
return; printf("\t--font <file>\t\tuse font <file> or <name>\n");
} printf("\t--fontsize <size>\tManually set fontsize\n");
new_job->type = type; printf("\t--writepng <file>\tinstead of printing, write output to png file\n");
if (type == JOB_TEXT && n > MAX_LINES) { printf("\t--force-tape-width <px>\tSet tape width in pixels, use together with\n");
n = MAX_LINES; printf("\t\t\t\t--writepng without a printer connected.\n");
} printf("\t--copies <number>\tSets the number of identical prints\n");
new_job->n = n; printf("print commands:\n");
new_job->lines[0] = line; printf("\t--image <file>\t\tprint the given image which must be a 2 color\n");
for (int i=1; i<MAX_LINES; ++i) { printf("\t\t\t\t(black/white) png\n");
new_job->lines[i] = NULL; printf("\t--text <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");
new_job->next = NULL; 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");
if (!last_added_job) { // just created the first job printf("\t--chain\t\t\tSkip final feed of label and any automatic cut\n");
jobs = last_added_job = new_job; printf("other commands:\n");
return; 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");
last_added_job->next = new_job; exit(1);
last_added_job = new_job;
} }
static error_t parse_opt(int key, char *arg, struct argp_state *state) /* here we don't print anything, but just try to catch syntax errors */
int parse_args(int argc, char **argv)
{ {
struct arguments *arguments = (struct arguments *)state->input; int lines, i;
switch (key) { for (i=1; i<argc; ++i) {
case 1: // debug if (*argv[i] != '-') {
arguments->debug = true;
break; break;
case 2: // font }
arguments->font_file = arg; if (strcmp(&argv[i][1], "-font") == 0) {
break; if (i+1<argc) {
case 3: // fontsize font_file=argv[++i];
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 7: // timeout
arguments->timeout = strtol(arg, NULL, 10);
break;
case 'i': // image
add_job(JOB_IMAGE, 1, arg);
break;
case 't': // text
//printf("adding text job with alignment %i\n", arguments->align);
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 11: // precut
arguments->precut = true;
break;
case 'a': // align
if ((strcmp(arg, "c") == 0) || (strcmp(arg, "center") == 0)) {
arguments->align = ALIGN_CENTER;
} else if ((strcmp(arg, "r") == 0) || (strcmp(arg, "right") == 0)) {
arguments->align = ALIGN_RIGHT;
} else if ((strcmp(arg, "l") == 0) || (strcmp(arg, "left") == 0)) {
arguments->align = ALIGN_LEFT;
} else { } else {
printf("unknown alignment, defaulting to left\n"); usage(argv[0]);
arguments->align = ALIGN_LEFT;
} }
break; } else if (strcmp(&argv[i][1], "-fontsize") == 0) {
case 'n': // newline if (i+1<argc) {
if (!last_added_job || last_added_job->type != JOB_TEXT) { ++i;
add_job(JOB_TEXT, 1, arg); } else {
break; usage(argv[0]);
} }
} else if (strcmp(&argv[i][1], "-writepng") == 0) {
if (last_added_job->n >= MAX_LINES) { // max number of lines reached if (i+1<argc) {
argp_failure(state, 1, EINVAL, _("Only up to %d lines are supported"), MAX_LINES); save_png=argv[++i];
break; } else {
usage(argv[0]);
} }
} else if (strcmp(&argv[i][1], "-force-tape-width") == 0) {
last_added_job->lines[last_added_job->n++] = arg; if (i+1<argc) {
break; forced_tape_width=strtol(argv[++i], NULL, 10);
case 20: // info } else {
arguments->info = true; usage(argv[0]);
break; }
case 21: // list-supported } 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) {
ptouch_list_supported(); ptouch_list_supported();
exit(0); exit(0);
case ARGP_KEY_ARG: } else {
argp_failure(state, 1, E2BIG, _("No arguments supported")); usage(argv[0]);
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;
} }
return 0; if (forced_tape_width && !save_png) {
forced_tape_width = 0;
}
return i;
} }
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
int print_width = 0; int i, lines = 0, tape_width, copies=1;
gdImage *im = NULL; char *line[MAX_LINES];
gdImage *out = NULL; gdImage *im=NULL;
ptouch_dev ptdev = NULL; gdImage *out=NULL;
ptouch_dev ptdev=NULL;
setlocale(LC_ALL, ""); setlocale(LC_ALL, "");
const char *textdomain_dir = getenv("TEXTDOMAINDIR"); bindtextdomain("ptouch-print", "/usr/share/locale/");
if (!textdomain_dir) { textdomain("ptouch-print");
textdomain_dir = "/usr/share/locale/"; i=parse_args(argc, argv);
if (i != argc) {
usage(argv[0]);
} }
bindtextdomain(P_NAME, "/usr/share/locale/"); if (!forced_tape_width) {
textdomain(P_NAME);
argp_parse(&argp, argc, argv, 0, 0, &arguments);
if (!arguments.forced_tape_width) {
if ((ptouch_open(&ptdev)) < 0) { if ((ptouch_open(&ptdev)) < 0) {
return 5; return 5;
} }
if (ptouch_init(ptdev) != 0) { if (ptouch_init(ptdev) != 0) {
printf(_("ptouch_init() failed\n")); printf(_("ptouch_init() failed\n"));
} }
if (ptouch_getstatus(ptdev, arguments.timeout) != 0) { if (ptouch_getstatus(ptdev) != 0) {
printf(_("ptouch_getstatus() failed\n")); printf(_("ptouch_getstatus() failed\n"));
return 1; return 1;
} }
print_width = ptouch_get_tape_width(ptdev); tape_width=ptouch_get_tape_width(ptdev);
int max_print_width = ptouch_get_max_width(ptdev); } else {
// do not try to print more pixels than printhead has tape_width = forced_tape_width;
if (print_width > max_print_width) {
print_width = max_print_width;
}
} else { // --forced_tape_width together with --writepng
print_width = arguments.forced_tape_width;
} }
for (i=1; i<argc; ++i) {
if (arguments.info) { if (*argv[i] != '-') {
printf(_("maximum printing width for this printer is %ldpx\n"), ptouch_get_max_width(ptdev)); break;
printf(_("maximum printing width for this tape is %ldpx\n"), ptouch_get_tape_width(ptdev));
printf("media type = 0x%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 = 0x%02x (%s)\n", ptdev->status->tape_color, pt_tapecolor(ptdev->status->tape_color));
printf("text color = 0x%02x (%s)\n", ptdev->status->text_color, pt_textcolor(ptdev->status->text_color));
printf("error = 0x%04x\n", ptdev->status->error);
if (arguments.debug) {
ptouch_rawstatus((uint8_t *)ptdev->status);
} }
exit(0); if (strcmp(&argv[i][1], "-font") == 0) {
} if (i+1<argc) {
font_file=argv[++i];
// iterate through all print jobs } else {
for (job_t *job = jobs; job != NULL; job = job->next) { usage(argv[0]);
if (arguments.debug) {
printf("job %p: type=%d | n=%d", job, job->type, job->n);
for (int i=0; i<MAX_LINES; ++i) {
printf(" | %s", job->lines[i]);
} }
printf(" | next=%p\n", job->next); } else if (strcmp(&argv[i][1], "-fontsize") == 0) {
} if (i+1<argc) {
fontsize=strtol(argv[++i], NULL, 10);
switch (job->type) { } else {
case JOB_IMAGE: usage(argv[0]);
if ((im = image_load(job->lines[0])) == NULL) { }
printf(_("failed to load image file\n")); } else if (strcmp(&argv[i][1], "-force-tape-width") == 0) {
return 1; 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 tape is %ipx\n"), tape_width);
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;
} }
out = img_append(out, im); ++i;
gdImageDestroy(im); line[lines]=argv[i];
im = NULL; }
break; if (lines) {
case JOB_TEXT: if ((im=render_text(font_file, line, lines, tape_width)) == NULL) {
if ((im = render_text(arguments.font_file, job->lines, job->n, 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;
break; }
case JOB_CUTMARK: } else if (strcmp(&argv[i][1], "-cutmark") == 0) {
im = img_cutmark(print_width); im=img_cutmark(tape_width);
out = img_append(out, im); out=img_append(out, im);
gdImageDestroy(im); gdImageDestroy(im);
im = NULL; im = NULL;
break; } else if (strcmp(&argv[i][1], "-pad") == 0) {
case JOB_PAD: int length=strtol(argv[++i], NULL, 10);
im = img_padding(print_width, job->n); im=img_padding(tape_width, length);
out = img_append(out, im); out=img_append(out, im);
gdImageDestroy(im); gdImageDestroy(im);
im = NULL; im = NULL;
break; } else if (strcmp(&argv[i][1], "-chain") == 0) {
default: chain = true;
break; } 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]);
} }
} }
// 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 (out) {
if (arguments.save_png) { if (save_png) {
write_png(out, arguments.save_png); write_png(out, save_png);
} else { } else {
for (int i = 0; i < arguments.copies; ++i) { for (i=0; i<copies; ++i) {
print_img(ptdev, out, arguments.chain, arguments.precut); print_img(ptdev, out, chain);
if (ptouch_finalize(ptdev, ( arguments.chain || (i < arguments.copies-1) ) ) != 0) { if (ptouch_finalize(ptdev, ( chain || (i < copies-1) ) ) != 0) {
printf(_("ptouch_finalize(%d) failed\n"), arguments.chain); printf(_("ptouch_finalize(%d) failed\n"), chain);
return 2; return 2;
} }
} }
@ -743,7 +659,7 @@ int main(int argc, char *argv[])
if (im != NULL) { if (im != NULL) {
gdImageDestroy(im); gdImageDestroy(im);
} }
if (!arguments.forced_tape_width) { if (!forced_tape_width) {
ptouch_close(ptdev); ptouch_close(ptdev);
} }
libusb_exit(NULL); libusb_exit(NULL);

View file

@ -1,5 +1,4 @@
# Enable non-root access for known ptouch printers # 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} == "2007", MODE="0660", TAG+="uaccess"
SUBSYSTEM == "usb", ATTRS{idVendor} == "04f9", ATTRS{idProduct} == "2011", 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} == "2019", MODE="0660", TAG+="uaccess"
@ -17,4 +16,3 @@ 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} == "20df", MODE="0660", TAG+="uaccess"
SUBSYSTEM == "usb", ATTRS{idVendor} == "04f9", ATTRS{idProduct} == "20e0", 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} == "20e1", MODE="0660", TAG+="uaccess"
SUBSYSTEM == "usb", ATTRS{idVendor} == "04f9", ATTRS{idProduct} == "2201", MODE="0660", TAG+="uaccess"