From fd526f9dbe4df888b0aa14ccc570fc9d3f8ada29 Mon Sep 17 00:00:00 2001 From: Dominic Radermacher Date: Mon, 8 Dec 2025 15:33:06 +0100 Subject: [PATCH] add param --align for aligning multi-line text centered or right-aligned --- po/de.po | 118 ++++++++++++++++++++-------------------- po/en.po | 118 ++++++++++++++++++++-------------------- po/ptouch.pot | 132 ++++++++++++++++++++++----------------------- src/libptouch.c | 11 +++- src/ptouch-print.c | 29 ++++++++-- 5 files changed, 220 insertions(+), 188 deletions(-) diff --git a/po/de.po b/po/de.po index c0e202b..1219aa5 100644 --- a/po/de.po +++ b/po/de.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: ptouch-print 1.3.1\n" "Report-Msgid-Bugs-To: dominic@familie-radermacher.ch\n" -"POT-Creation-Date: 2025-10-31 08:04+0100\n" +"POT-Creation-Date: 2025-12-08 15:27+0100\n" "PO-Revision-Date: 2024-05-23 22:27-0400\n" "Last-Translator: dominic@familie-radermacher.ch\n" "Language-Team: German \n" @@ -19,285 +19,285 @@ msgstr "" "Plural-Forms: nplurals=2; plural=(n != 1);\n" "X-Generator: Poedit 2.4.2\n" -#: src/libptouch.c:106 src/libptouch.c:110 src/libptouch.c:114 +#: src/libptouch.c:107 src/libptouch.c:111 src/libptouch.c:115 #, c-format msgid "out of memory\n" msgstr "Nicht genug Speicher\n" -#: src/libptouch.c:118 +#: src/libptouch.c:119 #, c-format msgid "libusb_init() failed\n" msgstr "ptouch_init() fehlgeschlagen\n" -#: src/libptouch.c:127 +#: src/libptouch.c:128 #, c-format msgid "failed to get device descriptor" msgstr "" -#: src/libptouch.c:133 +#: src/libptouch.c:134 #, c-format msgid "%s found on USB bus %d, device %d\n" msgstr "Drucker %s am USB Bus %d, Gerät %d gefunden\n" -#: src/libptouch.c:148 +#: src/libptouch.c:149 #, c-format msgid "libusb_open error :%s\n" msgstr "" -#: src/libptouch.c:154 +#: src/libptouch.c:155 #, c-format msgid "error while detaching kernel driver: %s\n" msgstr "" -#: src/libptouch.c:158 +#: src/libptouch.c:159 #, c-format msgid "interface claim error: %s\n" msgstr "" -#: src/libptouch.c:169 +#: src/libptouch.c:170 #, c-format msgid "" "No P-Touch printer found on USB (remember to put switch to position E)\n" msgstr "Kein P-Ptouch Drucker am USB gefunden (Schalter muss auf E stehen)\n" -#: src/libptouch.c:189 +#: src/libptouch.c:190 #, c-format msgid "debug: called ptouch_send() with NULL ptdev\n" msgstr "" -#: src/libptouch.c:196 +#: src/libptouch.c:197 #, c-format msgid "write error: %s\n" msgstr "" -#: src/libptouch.c:200 +#: src/libptouch.c:201 #, fuzzy, c-format msgid "write error: could send only %i of %ld bytes\n" msgstr "Lesefehler: %i anstatt 32 bytes empfangen\n" -#: src/libptouch.c:250 +#: src/libptouch.c:251 #, c-format msgid "debug: called ptouch_info_cmd() with NULL ptdev\n" msgstr "" -#: src/libptouch.c:292 +#: src/libptouch.c:293 #, fuzzy, c-format msgid "debug: called ptouch_rasterstart() with NULL ptdev\n" msgstr "ptouch_rasterstart() fehlgeschlagen\n" -#: src/libptouch.c:323 +#: src/libptouch.c:324 #, c-format msgid "debug: called ptouch_finalize() with NULL ptdev\n" msgstr "" -#: src/libptouch.c:338 +#: src/libptouch.c:339 #, c-format msgid "debug: dumping raw status bytes\n" msgstr "" -#: src/libptouch.c:357 +#: src/libptouch.c:358 #, c-format msgid "debug: called ptouch_getstatus() with NULL ptdev\n" msgstr "" -#: src/libptouch.c:367 src/libptouch.c:403 +#: src/libptouch.c:368 src/libptouch.c:404 #, c-format msgid "read error: %s\n" msgstr "" -#: src/libptouch.c:372 +#: src/libptouch.c:373 #, c-format msgid "timeout (%i sec) while waiting for status response\n" msgstr "" -#: src/libptouch.c:386 +#: src/libptouch.c:387 #, c-format msgid "unknown tape width of %imm, please report this.\n" msgstr "Unbekannte Schriftband breite (%i mm), bitte melden\n" -#: src/libptouch.c:392 +#: src/libptouch.c:393 #, c-format msgid "got only 16 bytes... wondering what they are:\n" msgstr "nur 16 bytes empfangen... mal gucken was die sind:\n" -#: src/libptouch.c:396 +#: src/libptouch.c:397 #, c-format msgid "read error: got %i instead of 32 bytes\n" msgstr "Lesefehler: %i anstatt 32 bytes empfangen\n" -#: src/libptouch.c:399 +#: src/libptouch.c:400 #, c-format msgid "strange status:\n" msgstr "Seltsamer Status:\n" -#: src/libptouch.c:401 +#: src/libptouch.c:402 #, c-format msgid "trying to flush junk\n" msgstr "" -#: src/libptouch.c:406 +#: src/libptouch.c:407 #, c-format msgid "got another %i bytes. now try again\n" msgstr "weitere %i bytes empfangen. probiere es nochmal.\n" -#: src/libptouch.c:413 +#: src/libptouch.c:414 #, c-format msgid "debug: called ptouch_get_tape_width() with NULL ptdev\n" msgstr "" -#: src/libptouch.c:422 +#: src/libptouch.c:423 #, c-format msgid "debug: called ptouch_get_max_width() with NULL ptdev\n" msgstr "" -#: src/libptouch.c:434 +#: src/libptouch.c:435 #, c-format msgid "debug: called ptouch_sendraster() with NULL ptdev\n" msgstr "" -#: src/ptouch-print.c:146 +#: src/ptouch-print.c:152 #, c-format msgid "nothing to print\n" msgstr "" -#: src/ptouch-print.c:154 +#: src/ptouch-print.c:160 #, c-format msgid "image is too large (%ipx x %ipx)\n" msgstr "Bild ist zu gross (%ipx x %ipx)\n" -#: src/ptouch-print.c:155 +#: src/ptouch-print.c:161 #, c-format msgid "maximum printing width for this tape is %ipx\n" msgstr "Maximal druckbare Breite für dieses Schriftband sind %ipx\n" -#: src/ptouch-print.c:158 +#: src/ptouch-print.c:164 #, fuzzy, c-format msgid "image size (%ipx x %ipx)\n" msgstr "Bild ist zu gross (%ipx x %ipx)\n" -#: src/ptouch-print.c:168 +#: src/ptouch-print.c:174 #, c-format msgid "ptouch_rasterstart() failed\n" msgstr "ptouch_rasterstart() fehlgeschlagen\n" -#: src/ptouch-print.c:174 +#: src/ptouch-print.c:180 #, c-format msgid "send print information command\n" msgstr "" -#: src/ptouch-print.c:180 +#: src/ptouch-print.c:186 #, c-format msgid "send PT-D460BT magic commands\n" msgstr "" -#: src/ptouch-print.c:186 +#: src/ptouch-print.c:193 #, c-format msgid "send precut command\n" msgstr "" -#: src/ptouch-print.c:194 +#: src/ptouch-print.c:202 #, c-format msgid "send PT-D460BT chain commands\n" msgstr "" -#: src/ptouch-print.c:206 +#: src/ptouch-print.c:214 #, fuzzy, c-format msgid "ptouch_sendraster() failed\n" msgstr "ptouch_send() fehlgeschlagen\n" -#: src/ptouch-print.c:255 +#: src/ptouch-print.c:263 #, c-format msgid "writing image '%s' failed\n" msgstr "Schreiben der Bilddatei '%s' fehlgeschlagen\n" -#: src/ptouch-print.c:277 +#: src/ptouch-print.c:285 #, c-format msgid "debug: o baseline offset - %d\n" msgstr "" -#: src/ptouch-print.c:278 +#: src/ptouch-print.c:286 #, c-format msgid "debug: text baseline offset - %d\n" msgstr "" -#: src/ptouch-print.c:337 +#: src/ptouch-print.c:345 #, c-format -msgid "render_text(): %i lines, font = '%s'\n" +msgid "render_text(): %i lines, font = '%s', align = '%c'\n" msgstr "" -#: src/ptouch-print.c:340 +#: src/ptouch-print.c:348 #, c-format msgid "warning: font config not available\n" msgstr "Warnung: fontconfig ist nicht verfügbar\n" -#: src/ptouch-print.c:344 +#: src/ptouch-print.c:352 #, c-format msgid "setting font size=%i\n" msgstr "setze Zeichensatzgrösse=%i\n" -#: src/ptouch-print.c:348 +#: src/ptouch-print.c:356 #, c-format msgid "could not estimate needed font size\n" msgstr "Konnte die notwendige Zeichensatzgrösse nicht bestimmen\n" -#: src/ptouch-print.c:355 +#: src/ptouch-print.c:363 #, c-format msgid "choosing font size=%i\n" msgstr "Wähle Zeichensatzgrösse %i\n" -#: src/ptouch-print.c:371 src/ptouch-print.c:399 +#: src/ptouch-print.c:379 src/ptouch-print.c:413 #, c-format msgid "error in gdImageStringFT: %s\n" msgstr "Fehler in Funktion gdImageStringFT(): %s\n" -#: src/ptouch-print.c:563 +#: src/ptouch-print.c:593 #, c-format msgid "Only up to %d lines are supported" msgstr "" -#: src/ptouch-print.c:576 +#: src/ptouch-print.c:606 msgid "No arguments supported" msgstr "" -#: src/ptouch-print.c:581 +#: src/ptouch-print.c:611 msgid "Option --writepng missing" msgstr "" -#: src/ptouch-print.c:584 +#: src/ptouch-print.c:614 msgid "Options --force_tape_width and --info can't be used together" msgstr "" -#: src/ptouch-print.c:615 +#: src/ptouch-print.c:645 #, c-format msgid "ptouch_init() failed\n" msgstr "ptouch_init() fehlgeschlagen\n" -#: src/ptouch-print.c:618 +#: src/ptouch-print.c:648 #, c-format msgid "ptouch_getstatus() failed\n" msgstr "ptouch_getstatus() fehlgeschlagen\n" -#: src/ptouch-print.c:632 +#: src/ptouch-print.c:662 #, 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:633 +#: 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:658 +#: src/ptouch-print.c:688 #, c-format msgid "failed to load image file\n" msgstr "" -#: src/ptouch-print.c:667 +#: src/ptouch-print.c:697 #, c-format msgid "could not render text\n" msgstr "Konnte Text nicht rendern\n" -#: src/ptouch-print.c:706 +#: src/ptouch-print.c:736 #, c-format msgid "ptouch_finalize(%d) failed\n" msgstr "ptouch_finalize(%d) fehlgeschlagen\n" diff --git a/po/en.po b/po/en.po index 5094e41..227ef71 100644 --- a/po/en.po +++ b/po/en.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: ptouch-print 1.3.1\n" "Report-Msgid-Bugs-To: dominic@familie-radermacher.ch\n" -"POT-Creation-Date: 2025-10-31 08:04+0100\n" +"POT-Creation-Date: 2025-12-08 15:27+0100\n" "PO-Revision-Date: 2024-05-23 22:26-0400\n" "Last-Translator: dominic@familie-radermacher.ch\n" "Language-Team: English \n" @@ -18,286 +18,286 @@ msgstr "" "Plural-Forms: nplurals=2; plural=(n != 1);\n" "X-Generator: Poedit 2.4.2\n" -#: src/libptouch.c:106 src/libptouch.c:110 src/libptouch.c:114 +#: src/libptouch.c:107 src/libptouch.c:111 src/libptouch.c:115 #, c-format msgid "out of memory\n" msgstr "out of memory\n" -#: src/libptouch.c:118 +#: src/libptouch.c:119 #, c-format msgid "libusb_init() failed\n" msgstr "libusb_init() failed\n" -#: src/libptouch.c:127 +#: src/libptouch.c:128 #, c-format msgid "failed to get device descriptor" msgstr "failed to get device descriptor" -#: src/libptouch.c:133 +#: src/libptouch.c:134 #, c-format msgid "%s found on USB bus %d, device %d\n" msgstr "%s found on USB bus %d, device %d\n" -#: src/libptouch.c:148 +#: src/libptouch.c:149 #, c-format msgid "libusb_open error :%s\n" msgstr "libusb_open error :%s\n" -#: src/libptouch.c:154 +#: src/libptouch.c:155 #, c-format msgid "error while detaching kernel driver: %s\n" msgstr "error while detaching kernel driver: %s\n" -#: src/libptouch.c:158 +#: src/libptouch.c:159 #, c-format msgid "interface claim error: %s\n" msgstr "interface claim error: %s\n" -#: src/libptouch.c:169 +#: src/libptouch.c:170 #, c-format msgid "" "No P-Touch printer found on USB (remember to put switch to position E)\n" msgstr "" "No P-Touch printer found on USB (remember to put switch to position E)\n" -#: src/libptouch.c:189 +#: src/libptouch.c:190 #, c-format msgid "debug: called ptouch_send() with NULL ptdev\n" msgstr "" -#: src/libptouch.c:196 +#: src/libptouch.c:197 #, c-format msgid "write error: %s\n" msgstr "write error: %s\n" -#: src/libptouch.c:200 +#: src/libptouch.c:201 #, fuzzy, c-format msgid "write error: could send only %i of %ld bytes\n" msgstr "write error: could send only %i of %i bytes\n" -#: src/libptouch.c:250 +#: src/libptouch.c:251 #, c-format msgid "debug: called ptouch_info_cmd() with NULL ptdev\n" msgstr "" -#: src/libptouch.c:292 +#: src/libptouch.c:293 #, fuzzy, c-format msgid "debug: called ptouch_rasterstart() with NULL ptdev\n" msgstr "ptouch_rasterstart() failed\n" -#: src/libptouch.c:323 +#: src/libptouch.c:324 #, c-format msgid "debug: called ptouch_finalize() with NULL ptdev\n" msgstr "" -#: src/libptouch.c:338 +#: src/libptouch.c:339 #, c-format msgid "debug: dumping raw status bytes\n" msgstr "debug: dumping raw status bytes\n" -#: src/libptouch.c:357 +#: src/libptouch.c:358 #, c-format msgid "debug: called ptouch_getstatus() with NULL ptdev\n" msgstr "" -#: src/libptouch.c:367 src/libptouch.c:403 +#: src/libptouch.c:368 src/libptouch.c:404 #, c-format msgid "read error: %s\n" msgstr "read error: %s\n" -#: src/libptouch.c:372 +#: src/libptouch.c:373 #, fuzzy, c-format msgid "timeout (%i sec) while waiting for status response\n" msgstr "timeout while waiting for status response\n" -#: src/libptouch.c:386 +#: src/libptouch.c:387 #, c-format msgid "unknown tape width of %imm, please report this.\n" msgstr "unknown tape width of %imm, please report this.\n" -#: src/libptouch.c:392 +#: src/libptouch.c:393 #, c-format msgid "got only 16 bytes... wondering what they are:\n" msgstr "got only 16 bytes... wondering what they are:\n" -#: src/libptouch.c:396 +#: src/libptouch.c:397 #, c-format msgid "read error: got %i instead of 32 bytes\n" msgstr "read error: got %i instead of 32 bytes\n" -#: src/libptouch.c:399 +#: src/libptouch.c:400 #, c-format msgid "strange status:\n" msgstr "strange status:\n" -#: src/libptouch.c:401 +#: src/libptouch.c:402 #, c-format msgid "trying to flush junk\n" msgstr "trying to flush junk\n" -#: src/libptouch.c:406 +#: src/libptouch.c:407 #, c-format msgid "got another %i bytes. now try again\n" msgstr "got another %i bytes. now try again\n" -#: src/libptouch.c:413 +#: src/libptouch.c:414 #, c-format msgid "debug: called ptouch_get_tape_width() with NULL ptdev\n" msgstr "" -#: src/libptouch.c:422 +#: src/libptouch.c:423 #, c-format msgid "debug: called ptouch_get_max_width() with NULL ptdev\n" msgstr "" -#: src/libptouch.c:434 +#: src/libptouch.c:435 #, c-format msgid "debug: called ptouch_sendraster() with NULL ptdev\n" msgstr "" -#: src/ptouch-print.c:146 +#: src/ptouch-print.c:152 #, c-format msgid "nothing to print\n" msgstr "" -#: src/ptouch-print.c:154 +#: src/ptouch-print.c:160 #, c-format msgid "image is too large (%ipx x %ipx)\n" msgstr "image is too large (%ipx x %ipx)\n" -#: src/ptouch-print.c:155 +#: src/ptouch-print.c:161 #, c-format msgid "maximum printing width for this tape is %ipx\n" msgstr "maximum printing width for this tape is %ipx\n" -#: src/ptouch-print.c:158 +#: src/ptouch-print.c:164 #, fuzzy, c-format msgid "image size (%ipx x %ipx)\n" msgstr "image is too large (%ipx x %ipx)\n" -#: src/ptouch-print.c:168 +#: src/ptouch-print.c:174 #, c-format msgid "ptouch_rasterstart() failed\n" msgstr "ptouch_rasterstart() failed\n" -#: src/ptouch-print.c:174 +#: src/ptouch-print.c:180 #, c-format msgid "send print information command\n" msgstr "" -#: src/ptouch-print.c:180 +#: src/ptouch-print.c:186 #, c-format msgid "send PT-D460BT magic commands\n" msgstr "" -#: src/ptouch-print.c:186 +#: src/ptouch-print.c:193 #, c-format msgid "send precut command\n" msgstr "" -#: src/ptouch-print.c:194 +#: src/ptouch-print.c:202 #, c-format msgid "send PT-D460BT chain commands\n" msgstr "" -#: src/ptouch-print.c:206 +#: src/ptouch-print.c:214 #, c-format msgid "ptouch_sendraster() failed\n" msgstr "ptouch_sendraster() failed\n" -#: src/ptouch-print.c:255 +#: src/ptouch-print.c:263 #, c-format msgid "writing image '%s' failed\n" msgstr "writing image '%s' failed\n" -#: src/ptouch-print.c:277 +#: src/ptouch-print.c:285 #, c-format msgid "debug: o baseline offset - %d\n" msgstr "" -#: src/ptouch-print.c:278 +#: src/ptouch-print.c:286 #, c-format msgid "debug: text baseline offset - %d\n" msgstr "" -#: src/ptouch-print.c:337 +#: src/ptouch-print.c:345 #, c-format -msgid "render_text(): %i lines, font = '%s'\n" +msgid "render_text(): %i lines, font = '%s', align = '%c'\n" msgstr "" -#: src/ptouch-print.c:340 +#: src/ptouch-print.c:348 #, c-format msgid "warning: font config not available\n" msgstr "warning: font config not available\n" -#: src/ptouch-print.c:344 +#: src/ptouch-print.c:352 #, c-format msgid "setting font size=%i\n" msgstr "setting font size=%i\n" -#: src/ptouch-print.c:348 +#: src/ptouch-print.c:356 #, c-format msgid "could not estimate needed font size\n" msgstr "could not estimate needed font size\n" -#: src/ptouch-print.c:355 +#: src/ptouch-print.c:363 #, c-format msgid "choosing font size=%i\n" msgstr "choosing font size=%i\n" -#: src/ptouch-print.c:371 src/ptouch-print.c:399 +#: src/ptouch-print.c:379 src/ptouch-print.c:413 #, c-format msgid "error in gdImageStringFT: %s\n" msgstr "error in gdImageStringFT: %s\n" -#: src/ptouch-print.c:563 +#: src/ptouch-print.c:593 #, c-format msgid "Only up to %d lines are supported" msgstr "" -#: src/ptouch-print.c:576 +#: src/ptouch-print.c:606 msgid "No arguments supported" msgstr "" -#: src/ptouch-print.c:581 +#: src/ptouch-print.c:611 msgid "Option --writepng missing" msgstr "" -#: src/ptouch-print.c:584 +#: src/ptouch-print.c:614 msgid "Options --force_tape_width and --info can't be used together" msgstr "" -#: src/ptouch-print.c:615 +#: src/ptouch-print.c:645 #, c-format msgid "ptouch_init() failed\n" msgstr "ptouch_init() failed\n" -#: src/ptouch-print.c:618 +#: src/ptouch-print.c:648 #, c-format msgid "ptouch_getstatus() failed\n" msgstr "ptouch_getstatus() failed\n" -#: src/ptouch-print.c:632 +#: src/ptouch-print.c:662 #, 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:633 +#: 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:658 +#: src/ptouch-print.c:688 #, c-format msgid "failed to load image file\n" msgstr "" -#: src/ptouch-print.c:667 +#: src/ptouch-print.c:697 #, c-format msgid "could not render text\n" msgstr "could not render text\n" -#: src/ptouch-print.c:706 +#: src/ptouch-print.c:736 #, c-format msgid "ptouch_finalize(%d) failed\n" msgstr "ptouch_finalize(%d) failed\n" diff --git a/po/ptouch.pot b/po/ptouch.pot index 2b391cf..8cf5889 100644 --- a/po/ptouch.pot +++ b/po/ptouch.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: ptouch-print\n" "Report-Msgid-Bugs-To: dominic@familie-radermacher.ch\n" -"POT-Creation-Date: 2025-10-31 08:04+0100\n" +"POT-Creation-Date: 2025-12-08 15:31+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -17,285 +17,285 @@ msgstr "" "Content-Type: text/plain; charset=CHARSET\n" "Content-Transfer-Encoding: 8bit\n" -#: src/libptouch.c:106 src/libptouch.c:110 src/libptouch.c:114 +#: src/libptouch.c:107 src/libptouch.c:111 src/libptouch.c:115 #, c-format msgid "out of memory\n" msgstr "" -#: src/libptouch.c:118 +#: src/libptouch.c:119 #, c-format msgid "libusb_init() failed\n" msgstr "" -#: src/libptouch.c:127 +#: src/libptouch.c:128 #, c-format msgid "failed to get device descriptor" msgstr "" -#: src/libptouch.c:133 +#: src/libptouch.c:134 #, c-format msgid "%s found on USB bus %d, device %d\n" msgstr "" -#: src/libptouch.c:148 +#: src/libptouch.c:149 #, c-format msgid "libusb_open error :%s\n" msgstr "" -#: src/libptouch.c:154 +#: src/libptouch.c:155 #, c-format msgid "error while detaching kernel driver: %s\n" msgstr "" -#: src/libptouch.c:158 +#: src/libptouch.c:159 #, c-format msgid "interface claim error: %s\n" msgstr "" -#: src/libptouch.c:169 +#: src/libptouch.c:170 #, c-format msgid "" "No P-Touch printer found on USB (remember to put switch to position E)\n" msgstr "" -#: src/libptouch.c:189 +#: src/libptouch.c:190 #, c-format msgid "debug: called ptouch_send() with NULL ptdev\n" msgstr "" -#: src/libptouch.c:196 +#: src/libptouch.c:197 #, c-format msgid "write error: %s\n" msgstr "" -#: src/libptouch.c:200 +#: src/libptouch.c:201 #, c-format msgid "write error: could send only %i of %ld bytes\n" msgstr "" -#: src/libptouch.c:250 +#: src/libptouch.c:251 #, c-format msgid "debug: called ptouch_info_cmd() with NULL ptdev\n" msgstr "" -#: src/libptouch.c:292 +#: src/libptouch.c:293 #, c-format msgid "debug: called ptouch_rasterstart() with NULL ptdev\n" msgstr "" -#: src/libptouch.c:323 +#: src/libptouch.c:324 #, c-format msgid "debug: called ptouch_finalize() with NULL ptdev\n" msgstr "" -#: src/libptouch.c:338 +#: src/libptouch.c:339 #, c-format msgid "debug: dumping raw status bytes\n" msgstr "" -#: src/libptouch.c:357 +#: src/libptouch.c:358 #, c-format msgid "debug: called ptouch_getstatus() with NULL ptdev\n" msgstr "" -#: src/libptouch.c:367 src/libptouch.c:403 +#: src/libptouch.c:368 src/libptouch.c:404 #, c-format msgid "read error: %s\n" msgstr "" -#: src/libptouch.c:372 +#: src/libptouch.c:373 #, c-format msgid "timeout (%i sec) while waiting for status response\n" msgstr "" -#: src/libptouch.c:386 +#: src/libptouch.c:387 #, c-format msgid "unknown tape width of %imm, please report this.\n" msgstr "" -#: src/libptouch.c:392 +#: src/libptouch.c:393 #, c-format msgid "got only 16 bytes... wondering what they are:\n" msgstr "" -#: src/libptouch.c:396 +#: src/libptouch.c:397 #, c-format msgid "read error: got %i instead of 32 bytes\n" msgstr "" -#: src/libptouch.c:399 +#: src/libptouch.c:400 #, c-format msgid "strange status:\n" msgstr "" -#: src/libptouch.c:401 +#: src/libptouch.c:402 #, c-format msgid "trying to flush junk\n" msgstr "" -#: src/libptouch.c:406 +#: src/libptouch.c:407 #, c-format msgid "got another %i bytes. now try again\n" msgstr "" -#: src/libptouch.c:413 +#: src/libptouch.c:414 #, c-format msgid "debug: called ptouch_get_tape_width() with NULL ptdev\n" msgstr "" -#: src/libptouch.c:422 +#: src/libptouch.c:423 #, c-format msgid "debug: called ptouch_get_max_width() with NULL ptdev\n" msgstr "" -#: src/libptouch.c:434 +#: src/libptouch.c:435 #, c-format msgid "debug: called ptouch_sendraster() with NULL ptdev\n" msgstr "" -#: src/ptouch-print.c:146 +#: src/ptouch-print.c:152 #, c-format msgid "nothing to print\n" msgstr "" -#: src/ptouch-print.c:154 +#: src/ptouch-print.c:160 #, c-format msgid "image is too large (%ipx x %ipx)\n" msgstr "" -#: src/ptouch-print.c:155 +#: src/ptouch-print.c:161 #, c-format msgid "maximum printing width for this tape is %ipx\n" msgstr "" -#: src/ptouch-print.c:158 +#: src/ptouch-print.c:164 #, c-format msgid "image size (%ipx x %ipx)\n" msgstr "" -#: src/ptouch-print.c:168 +#: src/ptouch-print.c:174 #, c-format msgid "ptouch_rasterstart() failed\n" msgstr "" -#: src/ptouch-print.c:174 +#: src/ptouch-print.c:180 #, c-format msgid "send print information command\n" msgstr "" -#: src/ptouch-print.c:180 +#: src/ptouch-print.c:186 #, c-format msgid "send PT-D460BT magic commands\n" msgstr "" -#: src/ptouch-print.c:186 +#: src/ptouch-print.c:193 #, c-format msgid "send precut command\n" msgstr "" -#: src/ptouch-print.c:194 +#: src/ptouch-print.c:202 #, c-format msgid "send PT-D460BT chain commands\n" msgstr "" -#: src/ptouch-print.c:206 +#: src/ptouch-print.c:214 #, c-format msgid "ptouch_sendraster() failed\n" msgstr "" -#: src/ptouch-print.c:255 +#: src/ptouch-print.c:263 #, c-format msgid "writing image '%s' failed\n" msgstr "" -#: src/ptouch-print.c:277 +#: src/ptouch-print.c:285 #, c-format msgid "debug: o baseline offset - %d\n" msgstr "" -#: src/ptouch-print.c:278 +#: src/ptouch-print.c:286 #, c-format msgid "debug: text baseline offset - %d\n" msgstr "" -#: src/ptouch-print.c:337 +#: src/ptouch-print.c:345 #, c-format -msgid "render_text(): %i lines, font = '%s'\n" -msgstr "" - -#: src/ptouch-print.c:340 -#, c-format -msgid "warning: font config not available\n" -msgstr "" - -#: src/ptouch-print.c:344 -#, c-format -msgid "setting font size=%i\n" +msgid "render_text(): %i lines, font = '%s', align = '%c'\n" msgstr "" #: src/ptouch-print.c:348 #, c-format +msgid "warning: font config not available\n" +msgstr "" + +#: src/ptouch-print.c:352 +#, c-format +msgid "setting font size=%i\n" +msgstr "" + +#: src/ptouch-print.c:356 +#, c-format msgid "could not estimate needed font size\n" msgstr "" -#: src/ptouch-print.c:355 +#: src/ptouch-print.c:363 #, c-format msgid "choosing font size=%i\n" msgstr "" -#: src/ptouch-print.c:371 src/ptouch-print.c:399 +#: src/ptouch-print.c:379 src/ptouch-print.c:413 #, c-format msgid "error in gdImageStringFT: %s\n" msgstr "" -#: src/ptouch-print.c:563 +#: src/ptouch-print.c:593 #, c-format msgid "Only up to %d lines are supported" msgstr "" -#: src/ptouch-print.c:576 +#: src/ptouch-print.c:606 msgid "No arguments supported" msgstr "" -#: src/ptouch-print.c:581 +#: src/ptouch-print.c:611 msgid "Option --writepng missing" msgstr "" -#: src/ptouch-print.c:584 +#: src/ptouch-print.c:614 msgid "Options --force_tape_width and --info can't be used together" msgstr "" -#: src/ptouch-print.c:615 +#: src/ptouch-print.c:645 #, c-format msgid "ptouch_init() failed\n" msgstr "" -#: src/ptouch-print.c:618 +#: src/ptouch-print.c:648 #, c-format msgid "ptouch_getstatus() failed\n" msgstr "" -#: src/ptouch-print.c:632 +#: src/ptouch-print.c:662 #, c-format msgid "maximum printing width for this printer is %ldpx\n" msgstr "" -#: src/ptouch-print.c:633 +#: src/ptouch-print.c:663 #, c-format msgid "maximum printing width for this tape is %ldpx\n" msgstr "" -#: src/ptouch-print.c:658 +#: src/ptouch-print.c:688 #, c-format msgid "failed to load image file\n" msgstr "" -#: src/ptouch-print.c:667 +#: src/ptouch-print.c:697 #, c-format msgid "could not render text\n" msgstr "" -#: src/ptouch-print.c:706 +#: src/ptouch-print.c:736 #, c-format msgid "ptouch_finalize(%d) failed\n" msgstr "" diff --git a/src/libptouch.c b/src/libptouch.c index acfa066..29a69f9 100644 --- a/src/libptouch.c +++ b/src/libptouch.c @@ -457,12 +457,21 @@ int ptouch_sendraster(ptouch_dev ptdev, uint8_t *data, size_t len) void ptouch_list_supported() { + const int columns = 5; printf("Supported printers (some might have quirks)\n"); + int col=0; for (int i=0; ptdevs[i].vid > 0; ++i) { if ((ptdevs[i].flags & FLAG_PLITE) != FLAG_PLITE) { - printf("\t%s\n", ptdevs[i].name); + printf("%s", 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; } diff --git a/src/ptouch-print.c b/src/ptouch-print.c index 8ff6851..bc0ae4c 100644 --- a/src/ptouch-print.c +++ b/src/ptouch-print.c @@ -38,7 +38,10 @@ #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; @@ -51,7 +54,6 @@ struct arguments { int verbose; int timeout; }; - typedef enum { JOB_CUTMARK, JOB_IMAGE, JOB_PAD, JOB_TEXT, JOB_UNDEFINED } job_type_t; typedef struct job { @@ -99,6 +101,7 @@ static struct argp_option options[] = { { "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', "", 0, "Add text in a new line (up to 4 lines)", 2}, + { "align", 'a', "", 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}, @@ -109,6 +112,7 @@ static struct argp_option options[] = { 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, @@ -338,7 +342,7 @@ gdImage *render_text(char *font, char *line[], int lines, int print_width) gdImage *im = NULL; if (arguments.debug) { - printf(_("render_text(): %i lines, font = '%s'\n"), lines, font); + printf(_("render_text(): %i lines, font = '%s', align = '%c'\n"), lines, font, arguments.align); } if (gdFTUseFontConfig(1) != GD_TRUE) { printf(_("warning: font config not available\n")); @@ -399,7 +403,13 @@ gdImage *render_text(char *font, char *line[], int lines, int print_width) printf("debug: line %i pos=%i ofs=%i\n", i+1, pos, ofs); } int off_x = offset_x(line[i], arguments.font_file, fsz); - if ((p = gdImageStringFT(im, &brect[0], -black, font, fsz, 0.0, off_x, pos, line[i])) != NULL) { + int align_ofs = 0; + 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); } } @@ -546,6 +556,7 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) 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 @@ -560,6 +571,18 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) 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 { + printf("unknown alignment, defaulting to left\n"); + arguments->align = ALIGN_LEFT; + } + break; case 'n': // newline if (!last_added_job || last_added_job->type != JOB_TEXT) { add_job(JOB_TEXT, 1, arg);