diff --git a/include/ptouch.h b/include/ptouch.h index 95785df..7378c37 100644 --- a/include/ptouch.h +++ b/include/ptouch.h @@ -103,6 +103,7 @@ int ptouch_init(ptouch_dev ptdev); int ptouch_lf(ptouch_dev ptdev); int ptouch_ff(ptouch_dev ptdev); int ptouch_get_dpi(ptouch_dev ptdev); +int ptouch_calc_tape_px(ptouch_dev ptdev, const uint8_t tape_with_mm); size_t ptouch_get_max_width(ptouch_dev ptdev); size_t ptouch_get_tape_width(ptouch_dev ptdev); int ptouch_get_max_lines(ptouch_dev ptdev, int fontsize_px); diff --git a/po/de.po b/po/de.po index c7d1da9..be284f3 100644 --- a/po/de.po +++ b/po/de.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: ptouch-print 1.7\n" "Report-Msgid-Bugs-To: dominic@familie-radermacher.ch\n" -"POT-Creation-Date: 2026-03-08 10:22+0100\n" +"POT-Creation-Date: 2026-03-08 13:10+0100\n" "PO-Revision-Date: 2024-05-23 22:27-0400\n" "Last-Translator: dominic@familie-radermacher.ch\n" "Language-Team: German \n" @@ -100,7 +100,7 @@ msgstr "" msgid "debug: called ptouch_getstatus() with NULL ptdev\n" msgstr "" -#: src/libptouch.c:369 src/libptouch.c:407 +#: src/libptouch.c:369 src/libptouch.c:400 #, c-format msgid "read error: %s\n" msgstr "" @@ -110,211 +110,216 @@ msgstr "" msgid "timeout (%i sec) while waiting for status response\n" msgstr "" -#: src/libptouch.c:390 +#: src/libptouch.c:383 #, c-format msgid "unknown tape width of %imm, please report this.\n" msgstr "Unbekannte Schriftband breite (%i mm), bitte melden\n" -#: src/libptouch.c:396 +#: src/libptouch.c:389 #, 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:400 +#: src/libptouch.c:393 #, c-format msgid "read error: got %i instead of 32 bytes\n" msgstr "Lesefehler: %i anstatt 32 bytes empfangen\n" -#: src/libptouch.c:403 +#: src/libptouch.c:396 #, c-format msgid "strange status:\n" msgstr "Seltsamer Status:\n" -#: src/libptouch.c:405 +#: src/libptouch.c:398 #, c-format msgid "trying to flush junk\n" msgstr "" -#: src/libptouch.c:410 +#: src/libptouch.c:403 #, c-format msgid "got another %i bytes. now try again\n" msgstr "weitere %i bytes empfangen. probiere es nochmal.\n" -#: src/libptouch.c:417 +#: src/libptouch.c:410 #, fuzzy, c-format msgid "debug: called ptouch_get_dpi() with NULL ptdev\n" msgstr "ptouch_rasterstart() fehlgeschlagen\n" +#: src/libptouch.c:419 +#, fuzzy, c-format +msgid "debug: called ptouch_cal_tape_width() with NULL ptdev\n" +msgstr "ptouch_rasterstart() fehlgeschlagen\n" + #: src/libptouch.c:430 +#, c-format +msgid "printer with %d dpi not supported\n" +msgstr "" + +#: src/libptouch.c:444 #, fuzzy, c-format msgid "debug: called ptouch_get_max_lines() with NULL ptdev\n" msgstr "ptouch_rasterstart() fehlgeschlagen\n" -#: src/libptouch.c:434 +#: src/libptouch.c:448 #, fuzzy, c-format msgid "debug: called ptouch_get_max_lines() with invalid fontsize_px\n" msgstr "ptouch_rasterstart() fehlgeschlagen\n" -#: src/libptouch.c:437 +#: src/libptouch.c:451 #, c-format msgid "debug: calculated max lines %d \n" msgstr "" -#: src/libptouch.c:444 +#: src/libptouch.c:458 #, c-format msgid "debug: called ptouch_get_tape_width() with NULL ptdev\n" msgstr "" -#: src/libptouch.c:453 +#: src/libptouch.c:467 #, c-format msgid "debug: called ptouch_get_max_width() with NULL ptdev\n" msgstr "" -#: src/libptouch.c:465 +#: src/libptouch.c:479 #, c-format msgid "debug: called ptouch_sendraster() with NULL ptdev\n" msgstr "" -#: src/ptouch-print.c:174 +#: src/ptouch-print.c:176 #, c-format msgid "nothing to print\n" msgstr "" -#: src/ptouch-print.c:182 +#: src/ptouch-print.c:184 #, c-format msgid "image is too large (%ipx x %ipx)\n" msgstr "Bild ist zu gross (%ipx x %ipx)\n" -#: src/ptouch-print.c:183 +#: src/ptouch-print.c:185 #, 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:186 +#: src/ptouch-print.c:188 #, fuzzy, c-format msgid "image size (%ipx x %ipx)\n" msgstr "Bild ist zu gross (%ipx x %ipx)\n" -#: src/ptouch-print.c:196 +#: src/ptouch-print.c:198 #, c-format msgid "ptouch_rasterstart() failed\n" msgstr "ptouch_rasterstart() fehlgeschlagen\n" -#: src/ptouch-print.c:202 +#: src/ptouch-print.c:204 #, c-format msgid "send print information command\n" msgstr "" -#: src/ptouch-print.c:208 +#: src/ptouch-print.c:210 #, c-format msgid "send PT-D460BT magic commands\n" msgstr "" -#: src/ptouch-print.c:215 +#: src/ptouch-print.c:217 #, c-format msgid "send precut command\n" msgstr "" -#: src/ptouch-print.c:224 +#: src/ptouch-print.c:226 #, c-format msgid "send PT-D460BT chain commands\n" msgstr "" -#: src/ptouch-print.c:236 +#: src/ptouch-print.c:238 #, fuzzy, c-format msgid "ptouch_sendraster() failed\n" msgstr "ptouch_send() fehlgeschlagen\n" -#: src/ptouch-print.c:285 +#: src/ptouch-print.c:287 #, c-format msgid "writing image '%s' failed\n" msgstr "Schreiben der Bilddatei '%s' fehlgeschlagen\n" -#: src/ptouch-print.c:291 +#: src/ptouch-print.c:292 #, c-format msgid "printing '%s' requires %.1f mm of tape\n" msgstr "" -#: src/ptouch-print.c:313 +#: src/ptouch-print.c:314 #, c-format msgid "debug: z baseline offset - %d\n" msgstr "" -#: src/ptouch-print.c:314 +#: src/ptouch-print.c:315 #, c-format msgid "debug: text baseline offset - %d\n" msgstr "" -#: src/ptouch-print.c:387 +#: src/ptouch-print.c:388 #, c-format msgid "render_text(): %i lines, font = '%s', align = '%c'\n" msgstr "" -#: src/ptouch-print.c:390 +#: src/ptouch-print.c:391 #, c-format msgid "warning: font config not available\n" msgstr "Warnung: fontconfig ist nicht verfügbar\n" -#: src/ptouch-print.c:394 +#: src/ptouch-print.c:395 #, c-format msgid "setting font size=%i\n" msgstr "setze Zeichensatzgrösse=%i\n" -#: src/ptouch-print.c:396 +#: src/ptouch-print.c:397 #, fuzzy, c-format msgid "ignoring setting font margin=%i\n" msgstr "setze Zeichensatzgrösse=%i\n" -#: src/ptouch-print.c:401 +#: src/ptouch-print.c:402 #, c-format msgid "could not estimate needed font size\n" msgstr "Konnte die notwendige Zeichensatzgrösse nicht bestimmen\n" -#: src/ptouch-print.c:408 +#: src/ptouch-print.c:409 #, c-format msgid "choosing font size=%i\n" msgstr "Wähle Zeichensatzgrösse %i\n" -#: src/ptouch-print.c:424 src/ptouch-print.c:458 +#: src/ptouch-print.c:425 src/ptouch-print.c:459 #, fuzzy, c-format msgid "error in gdImageStringFT_180dpi: %s\n" msgstr "Fehler in Funktion gdImageStringFT(): %s\n" -#: src/ptouch-print.c:615 +#: src/ptouch-print.c:616 #, c-format msgid "Only up to %d lines are supported" msgstr "" -#: src/ptouch-print.c:696 +#: src/ptouch-print.c:697 msgid "No arguments supported" msgstr "" -#: src/ptouch-print.c:701 +#: src/ptouch-print.c:702 msgid "Option --writepng missing" msgstr "" -#: src/ptouch-print.c:704 +#: src/ptouch-print.c:705 msgid "Options --force_tape_width and --info can't be used together" msgstr "" -#: src/ptouch-print.c:735 +#: src/ptouch-print.c:736 #, c-format msgid "ptouch_init() failed\n" msgstr "ptouch_init() fehlgeschlagen\n" -#: src/ptouch-print.c:738 +#: src/ptouch-print.c:739 #, c-format msgid "ptouch_getstatus() failed\n" msgstr "ptouch_getstatus() fehlgeschlagen\n" -#: src/ptouch-print.c:752 -#, c-format -msgid "printer has %d dpi\n" -msgstr "" - #: src/ptouch-print.c:753 #, fuzzy, c-format -msgid "maximum printing width for this printer is %ldpx\n" +msgid "printer has %d dpi, maximum printing width is %ld px\n" msgstr "Maximal druckbare Breite für dieses Schriftband sind %ipx\n" #: src/ptouch-print.c:754 @@ -332,11 +337,15 @@ msgstr "" msgid "could not render text\n" msgstr "Konnte Text nicht rendern\n" -#: src/ptouch-print.c:827 +#: src/ptouch-print.c:829 #, c-format msgid "ptouch_finalize(%d) failed\n" msgstr "ptouch_finalize(%d) fehlgeschlagen\n" +#, fuzzy, c-format +#~ msgid "maximum printing width for this printer is %ldpx\n" +#~ msgstr "Maximal druckbare Breite für dieses Schriftband sind %ipx\n" + #, c-format #~ msgid "ptouch-print version %s by Dominic Radermacher\n" #~ msgstr "ptouch-print Version %s von Dominic Radermacher\n" diff --git a/po/en.po b/po/en.po index b67f1dc..20a1080 100644 --- a/po/en.po +++ b/po/en.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: ptouch-print 1.7\n" "Report-Msgid-Bugs-To: dominic@familie-radermacher.ch\n" -"POT-Creation-Date: 2026-03-08 10:22+0100\n" +"POT-Creation-Date: 2026-03-08 13:10+0100\n" "PO-Revision-Date: 2024-05-23 22:26-0400\n" "Last-Translator: dominic@familie-radermacher.ch\n" "Language-Team: English \n" @@ -100,7 +100,7 @@ msgstr "debug: dumping raw status bytes\n" msgid "debug: called ptouch_getstatus() with NULL ptdev\n" msgstr "" -#: src/libptouch.c:369 src/libptouch.c:407 +#: src/libptouch.c:369 src/libptouch.c:400 #, c-format msgid "read error: %s\n" msgstr "read error: %s\n" @@ -110,211 +110,216 @@ msgstr "read error: %s\n" msgid "timeout (%i sec) while waiting for status response\n" msgstr "timeout while waiting for status response\n" -#: src/libptouch.c:390 +#: src/libptouch.c:383 #, 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:396 +#: src/libptouch.c:389 #, 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:400 +#: src/libptouch.c:393 #, 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:403 +#: src/libptouch.c:396 #, c-format msgid "strange status:\n" msgstr "strange status:\n" -#: src/libptouch.c:405 +#: src/libptouch.c:398 #, c-format msgid "trying to flush junk\n" msgstr "trying to flush junk\n" -#: src/libptouch.c:410 +#: src/libptouch.c:403 #, c-format msgid "got another %i bytes. now try again\n" msgstr "got another %i bytes. now try again\n" -#: src/libptouch.c:417 +#: src/libptouch.c:410 #, fuzzy, c-format msgid "debug: called ptouch_get_dpi() with NULL ptdev\n" msgstr "ptouch_rasterstart() failed\n" +#: src/libptouch.c:419 +#, fuzzy, c-format +msgid "debug: called ptouch_cal_tape_width() with NULL ptdev\n" +msgstr "ptouch_rasterstart() failed\n" + #: src/libptouch.c:430 +#, c-format +msgid "printer with %d dpi not supported\n" +msgstr "" + +#: src/libptouch.c:444 #, fuzzy, c-format msgid "debug: called ptouch_get_max_lines() with NULL ptdev\n" msgstr "ptouch_rasterstart() failed\n" -#: src/libptouch.c:434 +#: src/libptouch.c:448 #, fuzzy, c-format msgid "debug: called ptouch_get_max_lines() with invalid fontsize_px\n" msgstr "ptouch_rasterstart() failed\n" -#: src/libptouch.c:437 +#: src/libptouch.c:451 #, c-format msgid "debug: calculated max lines %d \n" msgstr "" -#: src/libptouch.c:444 +#: src/libptouch.c:458 #, c-format msgid "debug: called ptouch_get_tape_width() with NULL ptdev\n" msgstr "" -#: src/libptouch.c:453 +#: src/libptouch.c:467 #, c-format msgid "debug: called ptouch_get_max_width() with NULL ptdev\n" msgstr "" -#: src/libptouch.c:465 +#: src/libptouch.c:479 #, c-format msgid "debug: called ptouch_sendraster() with NULL ptdev\n" msgstr "" -#: src/ptouch-print.c:174 +#: src/ptouch-print.c:176 #, c-format msgid "nothing to print\n" msgstr "" -#: src/ptouch-print.c:182 +#: src/ptouch-print.c:184 #, c-format msgid "image is too large (%ipx x %ipx)\n" msgstr "image is too large (%ipx x %ipx)\n" -#: src/ptouch-print.c:183 +#: src/ptouch-print.c:185 #, 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:186 +#: src/ptouch-print.c:188 #, fuzzy, c-format msgid "image size (%ipx x %ipx)\n" msgstr "image is too large (%ipx x %ipx)\n" -#: src/ptouch-print.c:196 +#: src/ptouch-print.c:198 #, c-format msgid "ptouch_rasterstart() failed\n" msgstr "ptouch_rasterstart() failed\n" -#: src/ptouch-print.c:202 +#: src/ptouch-print.c:204 #, c-format msgid "send print information command\n" msgstr "" -#: src/ptouch-print.c:208 +#: src/ptouch-print.c:210 #, c-format msgid "send PT-D460BT magic commands\n" msgstr "" -#: src/ptouch-print.c:215 +#: src/ptouch-print.c:217 #, c-format msgid "send precut command\n" msgstr "" -#: src/ptouch-print.c:224 +#: src/ptouch-print.c:226 #, c-format msgid "send PT-D460BT chain commands\n" msgstr "" -#: src/ptouch-print.c:236 +#: src/ptouch-print.c:238 #, c-format msgid "ptouch_sendraster() failed\n" msgstr "ptouch_sendraster() failed\n" -#: src/ptouch-print.c:285 +#: src/ptouch-print.c:287 #, c-format msgid "writing image '%s' failed\n" msgstr "writing image '%s' failed\n" -#: src/ptouch-print.c:291 +#: src/ptouch-print.c:292 #, c-format msgid "printing '%s' requires %.1f mm of tape\n" msgstr "" -#: src/ptouch-print.c:313 +#: src/ptouch-print.c:314 #, c-format msgid "debug: z baseline offset - %d\n" msgstr "" -#: src/ptouch-print.c:314 +#: src/ptouch-print.c:315 #, c-format msgid "debug: text baseline offset - %d\n" msgstr "" -#: src/ptouch-print.c:387 +#: src/ptouch-print.c:388 #, c-format msgid "render_text(): %i lines, font = '%s', align = '%c'\n" msgstr "" -#: src/ptouch-print.c:390 +#: src/ptouch-print.c:391 #, c-format msgid "warning: font config not available\n" msgstr "warning: font config not available\n" -#: src/ptouch-print.c:394 +#: src/ptouch-print.c:395 #, c-format msgid "setting font size=%i\n" msgstr "setting font size=%i\n" -#: src/ptouch-print.c:396 +#: src/ptouch-print.c:397 #, fuzzy, c-format msgid "ignoring setting font margin=%i\n" msgstr "setting font size=%i\n" -#: src/ptouch-print.c:401 +#: src/ptouch-print.c:402 #, c-format msgid "could not estimate needed font size\n" msgstr "could not estimate needed font size\n" -#: src/ptouch-print.c:408 +#: src/ptouch-print.c:409 #, c-format msgid "choosing font size=%i\n" msgstr "choosing font size=%i\n" -#: src/ptouch-print.c:424 src/ptouch-print.c:458 +#: src/ptouch-print.c:425 src/ptouch-print.c:459 #, fuzzy, c-format msgid "error in gdImageStringFT_180dpi: %s\n" msgstr "error in gdImageStringFT: %s\n" -#: src/ptouch-print.c:615 +#: src/ptouch-print.c:616 #, c-format msgid "Only up to %d lines are supported" msgstr "" -#: src/ptouch-print.c:696 +#: src/ptouch-print.c:697 msgid "No arguments supported" msgstr "" -#: src/ptouch-print.c:701 +#: src/ptouch-print.c:702 msgid "Option --writepng missing" msgstr "" -#: src/ptouch-print.c:704 +#: src/ptouch-print.c:705 msgid "Options --force_tape_width and --info can't be used together" msgstr "" -#: src/ptouch-print.c:735 +#: src/ptouch-print.c:736 #, c-format msgid "ptouch_init() failed\n" msgstr "ptouch_init() failed\n" -#: src/ptouch-print.c:738 +#: src/ptouch-print.c:739 #, c-format msgid "ptouch_getstatus() failed\n" msgstr "ptouch_getstatus() failed\n" -#: src/ptouch-print.c:752 -#, c-format -msgid "printer has %d dpi\n" -msgstr "" - #: src/ptouch-print.c:753 #, fuzzy, c-format -msgid "maximum printing width for this printer is %ldpx\n" +msgid "printer has %d dpi, maximum printing width is %ld px\n" msgstr "maximum printing width for this tape is %ipx\n" #: src/ptouch-print.c:754 @@ -332,11 +337,15 @@ msgstr "" msgid "could not render text\n" msgstr "could not render text\n" -#: src/ptouch-print.c:827 +#: src/ptouch-print.c:829 #, c-format msgid "ptouch_finalize(%d) failed\n" msgstr "ptouch_finalize(%d) failed\n" +#, fuzzy, c-format +#~ msgid "maximum printing width for this printer is %ldpx\n" +#~ msgstr "maximum printing width for this tape is %ipx\n" + #, c-format #~ msgid "ptouch-print version %s by Dominic Radermacher\n" #~ msgstr "ptouch-print version %s by Dominic Radermacher\n" diff --git a/po/ptouch.pot b/po/ptouch.pot index 8a9a125..5230cdb 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: 2026-03-08 10:24+0100\n" +"POT-Creation-Date: 2026-03-08 13:11+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -98,7 +98,7 @@ msgstr "" msgid "debug: called ptouch_getstatus() with NULL ptdev\n" msgstr "" -#: src/libptouch.c:369 src/libptouch.c:407 +#: src/libptouch.c:369 src/libptouch.c:400 #, c-format msgid "read error: %s\n" msgstr "" @@ -108,211 +108,216 @@ msgstr "" msgid "timeout (%i sec) while waiting for status response\n" msgstr "" -#: src/libptouch.c:390 +#: src/libptouch.c:383 #, c-format msgid "unknown tape width of %imm, please report this.\n" msgstr "" -#: src/libptouch.c:396 +#: src/libptouch.c:389 #, c-format msgid "got only 16 bytes... wondering what they are:\n" msgstr "" -#: src/libptouch.c:400 +#: src/libptouch.c:393 #, c-format msgid "read error: got %i instead of 32 bytes\n" msgstr "" -#: src/libptouch.c:403 +#: src/libptouch.c:396 #, c-format msgid "strange status:\n" msgstr "" -#: src/libptouch.c:405 +#: src/libptouch.c:398 #, c-format msgid "trying to flush junk\n" msgstr "" -#: src/libptouch.c:410 +#: src/libptouch.c:403 #, c-format msgid "got another %i bytes. now try again\n" msgstr "" -#: src/libptouch.c:417 +#: src/libptouch.c:410 #, c-format msgid "debug: called ptouch_get_dpi() with NULL ptdev\n" msgstr "" +#: src/libptouch.c:419 +#, c-format +msgid "debug: called ptouch_cal_tape_width() with NULL ptdev\n" +msgstr "" + #: src/libptouch.c:430 #, c-format -msgid "debug: called ptouch_get_max_lines() with NULL ptdev\n" -msgstr "" - -#: src/libptouch.c:434 -#, c-format -msgid "debug: called ptouch_get_max_lines() with invalid fontsize_px\n" -msgstr "" - -#: src/libptouch.c:437 -#, c-format -msgid "debug: calculated max lines %d \n" +msgid "printer with %d dpi not supported\n" msgstr "" #: src/libptouch.c:444 #, c-format +msgid "debug: called ptouch_get_max_lines() with NULL ptdev\n" +msgstr "" + +#: src/libptouch.c:448 +#, c-format +msgid "debug: called ptouch_get_max_lines() with invalid fontsize_px\n" +msgstr "" + +#: src/libptouch.c:451 +#, c-format +msgid "debug: calculated max lines %d \n" +msgstr "" + +#: src/libptouch.c:458 +#, c-format msgid "debug: called ptouch_get_tape_width() with NULL ptdev\n" msgstr "" -#: src/libptouch.c:453 +#: src/libptouch.c:467 #, c-format msgid "debug: called ptouch_get_max_width() with NULL ptdev\n" msgstr "" -#: src/libptouch.c:465 +#: src/libptouch.c:479 #, c-format msgid "debug: called ptouch_sendraster() with NULL ptdev\n" msgstr "" -#: src/ptouch-print.c:174 +#: src/ptouch-print.c:176 #, c-format msgid "nothing to print\n" msgstr "" -#: src/ptouch-print.c:182 +#: src/ptouch-print.c:184 #, c-format msgid "image is too large (%ipx x %ipx)\n" msgstr "" -#: src/ptouch-print.c:183 +#: src/ptouch-print.c:185 #, c-format msgid "maximum printing width for this tape is %ipx\n" msgstr "" -#: src/ptouch-print.c:186 +#: src/ptouch-print.c:188 #, c-format msgid "image size (%ipx x %ipx)\n" msgstr "" -#: src/ptouch-print.c:196 +#: src/ptouch-print.c:198 #, c-format msgid "ptouch_rasterstart() failed\n" msgstr "" -#: src/ptouch-print.c:202 +#: src/ptouch-print.c:204 #, c-format msgid "send print information command\n" msgstr "" -#: src/ptouch-print.c:208 +#: src/ptouch-print.c:210 #, c-format msgid "send PT-D460BT magic commands\n" msgstr "" -#: src/ptouch-print.c:215 +#: src/ptouch-print.c:217 #, c-format msgid "send precut command\n" msgstr "" -#: src/ptouch-print.c:224 +#: src/ptouch-print.c:226 #, c-format msgid "send PT-D460BT chain commands\n" msgstr "" -#: src/ptouch-print.c:236 +#: src/ptouch-print.c:238 #, c-format msgid "ptouch_sendraster() failed\n" msgstr "" -#: src/ptouch-print.c:285 +#: src/ptouch-print.c:287 #, c-format msgid "writing image '%s' failed\n" msgstr "" -#: src/ptouch-print.c:291 +#: src/ptouch-print.c:292 #, c-format msgid "printing '%s' requires %.1f mm of tape\n" msgstr "" -#: src/ptouch-print.c:313 +#: src/ptouch-print.c:314 #, c-format msgid "debug: z baseline offset - %d\n" msgstr "" -#: src/ptouch-print.c:314 +#: src/ptouch-print.c:315 #, c-format msgid "debug: text baseline offset - %d\n" msgstr "" -#: src/ptouch-print.c:387 +#: src/ptouch-print.c:388 #, c-format msgid "render_text(): %i lines, font = '%s', align = '%c'\n" msgstr "" -#: src/ptouch-print.c:390 +#: src/ptouch-print.c:391 #, c-format msgid "warning: font config not available\n" msgstr "" -#: src/ptouch-print.c:394 +#: src/ptouch-print.c:395 #, c-format msgid "setting font size=%i\n" msgstr "" -#: src/ptouch-print.c:396 +#: src/ptouch-print.c:397 #, c-format msgid "ignoring setting font margin=%i\n" msgstr "" -#: src/ptouch-print.c:401 +#: src/ptouch-print.c:402 #, c-format msgid "could not estimate needed font size\n" msgstr "" -#: src/ptouch-print.c:408 +#: src/ptouch-print.c:409 #, c-format msgid "choosing font size=%i\n" msgstr "" -#: src/ptouch-print.c:424 src/ptouch-print.c:458 +#: src/ptouch-print.c:425 src/ptouch-print.c:459 #, c-format msgid "error in gdImageStringFT_180dpi: %s\n" msgstr "" -#: src/ptouch-print.c:615 +#: src/ptouch-print.c:616 #, c-format msgid "Only up to %d lines are supported" msgstr "" -#: src/ptouch-print.c:696 +#: src/ptouch-print.c:697 msgid "No arguments supported" msgstr "" -#: src/ptouch-print.c:701 +#: src/ptouch-print.c:702 msgid "Option --writepng missing" msgstr "" -#: src/ptouch-print.c:704 +#: src/ptouch-print.c:705 msgid "Options --force_tape_width and --info can't be used together" msgstr "" -#: src/ptouch-print.c:735 +#: src/ptouch-print.c:736 #, c-format msgid "ptouch_init() failed\n" msgstr "" -#: src/ptouch-print.c:738 +#: src/ptouch-print.c:739 #, c-format msgid "ptouch_getstatus() failed\n" msgstr "" -#: src/ptouch-print.c:752 -#, c-format -msgid "printer has %d dpi\n" -msgstr "" - #: src/ptouch-print.c:753 #, c-format -msgid "maximum printing width for this printer is %ldpx\n" +msgid "printer has %d dpi, maximum printing width is %ld px\n" msgstr "" #: src/ptouch-print.c:754 @@ -330,7 +335,7 @@ msgstr "" msgid "could not render text\n" msgstr "" -#: src/ptouch-print.c:827 +#: src/ptouch-print.c:829 #, c-format msgid "ptouch_finalize(%d) failed\n" msgstr "" diff --git a/src/libptouch.c b/src/libptouch.c index 81b81d4..92080be 100644 --- a/src/libptouch.c +++ b/src/libptouch.c @@ -378,14 +378,7 @@ int ptouch_getstatus(ptouch_dev ptdev, int timeout) if (tx == 32) { if (buf[0]==0x80 && buf[1]==0x20) { memcpy(ptdev->status, buf, 32); - ptdev->tape_width_px=0; - for (i=0; tape_info[i].mm > 0; ++i) { - if (tape_info[i].mm == buf[10]) { - /* TODO: should be adjusted according - to printer dpi ! */ - ptdev->tape_width_px=tape_info[i].px; - } - } + ptdev->tape_width_px = ptouch_calc_tape_px(ptdev, buf[10]); if (ptdev->tape_width_px == 0) { fprintf(stderr, _("unknown tape width of %imm, please report this.\n"), buf[10]); } @@ -420,6 +413,27 @@ int ptouch_get_dpi(ptouch_dev ptdev) return ptdev->devinfo->dpi; } +int ptouch_calc_tape_px(ptouch_dev ptdev, const uint8_t tape_width_mm) +{ + if (!ptdev) { + fprintf(stderr, _("debug: called ptouch_cal_tape_width() with NULL ptdev\n")); + return 0; + } + int tape_width_px = 0; + for (int i=0; tape_info[i].mm > 0; ++i) { + if (tape_info[i].mm == tape_width_mm) { + if (ptdev->devinfo->dpi == 180) { + tape_width_px = tape_info[i].px; + } else if (ptdev->devinfo->dpi == 360) { + tape_width_px = tape_info[i].px * 2; + } else { + fprintf(stderr, _("printer with %d dpi not supported\n"), ptdev->devinfo->dpi); + } + } + } + return tape_width_px; +} + /* TODO: The actual number of maximum lines should be calculated according to printer resolution, tapewidth and fontsize */ /* printer resolution is planned to be taken into account when calculating diff --git a/src/ptouch-print.c b/src/ptouch-print.c index 4487e15..648c823 100644 --- a/src/ptouch-print.c +++ b/src/ptouch-print.c @@ -90,10 +90,12 @@ static struct argp_option options[] = { { 0, 0, 0, 0, "options:", 1}, { "debug", 1, 0, 0, "Enable debug output", 1}, { "font", 2, "", 0, "Use font or ", 1}, - { "fontsize", 3, "", 0, "Manually set font size, or ...", 1}, - { "fontmargin", 4, "", 0, "Manually set font top/bottom margin (in px)", 1}, - { "write-png", 5, "", 0, "Instead of printing, write output to png ", 1}, - { "writepng", 5, "", OPTION_ALIAS, "alias for write-png", 1}, + { "font-size", 3, "", 0, "Manually set font size, or ...", 1}, + { "fontsize", 3, "", OPTION_ALIAS, "alias for font-size", 1}, + { "font-margin", 4, "", 0, "Manually set font top/bottom margin (in px)", 1}, + { "fontmargin", 4, "", OPTION_ALIAS, "alias for font-margin", 1}, + { "write-png", 'w', "", 0, "Instead of printing, write output to png ", 1}, + { "writepng", 'w', "", OPTION_ALIAS, "alias for write-png", 1}, { "force-tape-width", 6, "", 0, "Set tape width in pixels, use together with --writepng without a printer connected", 1}, { "copies", 7, "", 0, "Sets the number of identical prints", 1}, { "timeout", 8, "", 0, "Set timeout waiting for finishing previous job. Default:1, 0 means infinity", 1}, @@ -285,7 +287,6 @@ int write_png(gdImage *im, const char *file) printf(_("writing image '%s' failed\n"), file); return -1; } - gdImageSetResolution(im, 180, 180); gdImagePng(im, f); fclose(f); printf(_("printing '%s' requires %.1f mm of tape\n"), file, (float)gdImageSX(im) / gdImageResolutionX(im) * 25.4); @@ -640,7 +641,7 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) case 4: // fontmargin arguments->font_margin = strtol(arg, NULL, 10); break; - case 5: // writepng + case 'w': // write-png arguments->save_png = arg; break; case 6: // force-tape-width @@ -749,8 +750,7 @@ int main(int argc, char *argv[]) } if (arguments.info) { - printf(_("printer has %d dpi\n"), ptouch_get_dpi(ptdev)); - printf(_("maximum printing width for this printer is %ldpx\n"), ptouch_get_max_width(ptdev)); + printf(_("printer has %d dpi, maximum printing width is %ld px\n"), ptouch_get_dpi(ptdev), ptouch_get_max_width(ptdev)); 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); @@ -819,6 +819,8 @@ int main(int argc, char *argv[]) if (out) { if (arguments.save_png) { + int dpi = ptouch_get_dpi(ptdev); + gdImageSetResolution(out, dpi, dpi); write_png(out, arguments.save_png); } else { for (int i = 0; i < arguments.copies; ++i) {