From 9cd8a5bc22ad78656efa312586c81096219b7afd Mon Sep 17 00:00:00 2001 From: Dominic Radermacher Date: Sun, 8 Mar 2026 10:26:46 +0100 Subject: [PATCH] preparing for support of printers with 360 dpi --- include/ptouch.h | 4 +- po/de.po | 123 +++++++++++++++++++++++++++++---------------- po/en.po | 123 +++++++++++++++++++++++++++++---------------- po/ptouch.pot | 121 ++++++++++++++++++++++++++++---------------- src/libptouch.c | 29 +++++++++++ src/ptouch-print.c | 13 +++-- 6 files changed, 278 insertions(+), 135 deletions(-) diff --git a/include/ptouch.h b/include/ptouch.h index 1fc1d0c..95785df 100644 --- a/include/ptouch.h +++ b/include/ptouch.h @@ -1,7 +1,7 @@ /* ptouch-print - Print labels with images or text on a Brother P-Touch - Copyright (C) 2015-2023 Dominic Radermacher + Copyright (C) 2015-2026 Dominic Radermacher This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 3 as @@ -102,8 +102,10 @@ int ptouch_send(ptouch_dev ptdev, uint8_t *data, size_t len); int ptouch_init(ptouch_dev ptdev); int ptouch_lf(ptouch_dev ptdev); int ptouch_ff(ptouch_dev ptdev); +int ptouch_get_dpi(ptouch_dev ptdev); 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); int ptouch_page_flags(ptouch_dev ptdev, uint8_t page_flags); int ptouch_finalize(ptouch_dev ptdev, int chain); int ptouch_getstatus(ptouch_dev ptdev, int timeout); diff --git a/po/de.po b/po/de.po index 2f0ba7a..c7d1da9 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-06 08:07+0100\n" +"POT-Creation-Date: 2026-03-08 10:22+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:405 +#: src/libptouch.c:369 src/libptouch.c:407 #, c-format msgid "read error: %s\n" msgstr "" @@ -110,194 +110,229 @@ msgstr "" msgid "timeout (%i sec) while waiting for status response\n" msgstr "" -#: src/libptouch.c:388 +#: src/libptouch.c:390 #, c-format msgid "unknown tape width of %imm, please report this.\n" msgstr "Unbekannte Schriftband breite (%i mm), bitte melden\n" -#: src/libptouch.c:394 +#: src/libptouch.c:396 #, 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:398 +#: src/libptouch.c:400 #, c-format msgid "read error: got %i instead of 32 bytes\n" msgstr "Lesefehler: %i anstatt 32 bytes empfangen\n" -#: src/libptouch.c:401 +#: src/libptouch.c:403 #, c-format msgid "strange status:\n" msgstr "Seltsamer Status:\n" -#: src/libptouch.c:403 +#: src/libptouch.c:405 #, c-format msgid "trying to flush junk\n" msgstr "" -#: src/libptouch.c:408 +#: src/libptouch.c:410 #, c-format msgid "got another %i bytes. now try again\n" msgstr "weitere %i bytes empfangen. probiere es nochmal.\n" -#: src/libptouch.c:415 +#: src/libptouch.c:417 +#, fuzzy, c-format +msgid "debug: called ptouch_get_dpi() with NULL ptdev\n" +msgstr "ptouch_rasterstart() fehlgeschlagen\n" + +#: src/libptouch.c:430 +#, fuzzy, c-format +msgid "debug: called ptouch_get_max_lines() with NULL ptdev\n" +msgstr "ptouch_rasterstart() fehlgeschlagen\n" + +#: src/libptouch.c:434 +#, fuzzy, c-format +msgid "debug: called ptouch_get_max_lines() with invalid fontsize_px\n" +msgstr "ptouch_rasterstart() fehlgeschlagen\n" + +#: src/libptouch.c:437 +#, c-format +msgid "debug: calculated max lines %d \n" +msgstr "" + +#: src/libptouch.c:444 #, c-format msgid "debug: called ptouch_get_tape_width() with NULL ptdev\n" msgstr "" -#: src/libptouch.c:424 +#: src/libptouch.c:453 #, c-format msgid "debug: called ptouch_get_max_width() with NULL ptdev\n" msgstr "" -#: src/libptouch.c:436 +#: src/libptouch.c:465 #, c-format msgid "debug: called ptouch_sendraster() with NULL ptdev\n" msgstr "" -#: src/ptouch-print.c:153 +#: src/ptouch-print.c:174 #, c-format msgid "nothing to print\n" msgstr "" -#: src/ptouch-print.c:161 +#: src/ptouch-print.c:182 #, c-format msgid "image is too large (%ipx x %ipx)\n" msgstr "Bild ist zu gross (%ipx x %ipx)\n" -#: src/ptouch-print.c:162 +#: src/ptouch-print.c:183 #, 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:165 +#: src/ptouch-print.c:186 #, fuzzy, c-format msgid "image size (%ipx x %ipx)\n" msgstr "Bild ist zu gross (%ipx x %ipx)\n" -#: src/ptouch-print.c:175 +#: src/ptouch-print.c:196 #, c-format msgid "ptouch_rasterstart() failed\n" msgstr "ptouch_rasterstart() fehlgeschlagen\n" -#: src/ptouch-print.c:181 +#: src/ptouch-print.c:202 #, c-format msgid "send print information command\n" msgstr "" -#: src/ptouch-print.c:187 +#: src/ptouch-print.c:208 #, c-format msgid "send PT-D460BT magic commands\n" msgstr "" -#: src/ptouch-print.c:194 +#: src/ptouch-print.c:215 #, c-format msgid "send precut command\n" msgstr "" -#: src/ptouch-print.c:203 +#: src/ptouch-print.c:224 #, c-format msgid "send PT-D460BT chain commands\n" msgstr "" -#: src/ptouch-print.c:215 +#: src/ptouch-print.c:236 #, fuzzy, c-format msgid "ptouch_sendraster() failed\n" msgstr "ptouch_send() fehlgeschlagen\n" -#: src/ptouch-print.c:264 +#: src/ptouch-print.c:285 #, c-format msgid "writing image '%s' failed\n" msgstr "Schreiben der Bilddatei '%s' fehlgeschlagen\n" -#: src/ptouch-print.c:286 +#: src/ptouch-print.c:291 #, c-format -msgid "debug: o baseline offset - %d\n" +msgid "printing '%s' requires %.1f mm of tape\n" msgstr "" -#: src/ptouch-print.c:287 +#: src/ptouch-print.c:313 +#, c-format +msgid "debug: z baseline offset - %d\n" +msgstr "" + +#: src/ptouch-print.c:314 #, c-format msgid "debug: text baseline offset - %d\n" msgstr "" -#: src/ptouch-print.c:346 +#: src/ptouch-print.c:387 #, c-format msgid "render_text(): %i lines, font = '%s', align = '%c'\n" msgstr "" -#: src/ptouch-print.c:349 +#: src/ptouch-print.c:390 #, c-format msgid "warning: font config not available\n" msgstr "Warnung: fontconfig ist nicht verfügbar\n" -#: src/ptouch-print.c:353 +#: src/ptouch-print.c:394 #, c-format msgid "setting font size=%i\n" msgstr "setze Zeichensatzgrösse=%i\n" -#: src/ptouch-print.c:357 +#: src/ptouch-print.c:396 +#, fuzzy, c-format +msgid "ignoring setting font margin=%i\n" +msgstr "setze Zeichensatzgrösse=%i\n" + +#: src/ptouch-print.c:401 #, c-format msgid "could not estimate needed font size\n" msgstr "Konnte die notwendige Zeichensatzgrösse nicht bestimmen\n" -#: src/ptouch-print.c:364 +#: src/ptouch-print.c:408 #, c-format msgid "choosing font size=%i\n" msgstr "Wähle Zeichensatzgrösse %i\n" -#: src/ptouch-print.c:380 src/ptouch-print.c:414 -#, c-format -msgid "error in gdImageStringFT: %s\n" +#: src/ptouch-print.c:424 src/ptouch-print.c:458 +#, fuzzy, c-format +msgid "error in gdImageStringFT_180dpi: %s\n" msgstr "Fehler in Funktion gdImageStringFT(): %s\n" -#: src/ptouch-print.c:571 +#: src/ptouch-print.c:615 #, c-format msgid "Only up to %d lines are supported" msgstr "" -#: src/ptouch-print.c:649 +#: src/ptouch-print.c:696 msgid "No arguments supported" msgstr "" -#: src/ptouch-print.c:654 +#: src/ptouch-print.c:701 msgid "Option --writepng missing" msgstr "" -#: src/ptouch-print.c:657 +#: src/ptouch-print.c:704 msgid "Options --force_tape_width and --info can't be used together" msgstr "" -#: src/ptouch-print.c:688 +#: src/ptouch-print.c:735 #, c-format msgid "ptouch_init() failed\n" msgstr "ptouch_init() fehlgeschlagen\n" -#: src/ptouch-print.c:691 +#: src/ptouch-print.c:738 #, c-format msgid "ptouch_getstatus() failed\n" msgstr "ptouch_getstatus() fehlgeschlagen\n" -#: src/ptouch-print.c:705 +#: 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" msgstr "Maximal druckbare Breite für dieses Schriftband sind %ipx\n" -#: src/ptouch-print.c:706 +#: src/ptouch-print.c:754 #, 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:731 +#: src/ptouch-print.c:779 #, c-format msgid "failed to load image file\n" msgstr "" -#: src/ptouch-print.c:740 +#: src/ptouch-print.c:788 #, c-format msgid "could not render text\n" msgstr "Konnte Text nicht rendern\n" -#: src/ptouch-print.c:779 +#: src/ptouch-print.c:827 #, 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 9c2db1a..b67f1dc 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-06 08:07+0100\n" +"POT-Creation-Date: 2026-03-08 10:22+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:405 +#: src/libptouch.c:369 src/libptouch.c:407 #, c-format msgid "read error: %s\n" msgstr "read error: %s\n" @@ -110,194 +110,229 @@ 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:388 +#: src/libptouch.c:390 #, 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:394 +#: src/libptouch.c:396 #, 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:398 +#: src/libptouch.c:400 #, 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:401 +#: src/libptouch.c:403 #, c-format msgid "strange status:\n" msgstr "strange status:\n" -#: src/libptouch.c:403 +#: src/libptouch.c:405 #, c-format msgid "trying to flush junk\n" msgstr "trying to flush junk\n" -#: src/libptouch.c:408 +#: src/libptouch.c:410 #, c-format msgid "got another %i bytes. now try again\n" msgstr "got another %i bytes. now try again\n" -#: src/libptouch.c:415 +#: src/libptouch.c:417 +#, fuzzy, c-format +msgid "debug: called ptouch_get_dpi() with NULL ptdev\n" +msgstr "ptouch_rasterstart() failed\n" + +#: src/libptouch.c:430 +#, fuzzy, c-format +msgid "debug: called ptouch_get_max_lines() with NULL ptdev\n" +msgstr "ptouch_rasterstart() failed\n" + +#: src/libptouch.c:434 +#, fuzzy, c-format +msgid "debug: called ptouch_get_max_lines() with invalid fontsize_px\n" +msgstr "ptouch_rasterstart() failed\n" + +#: src/libptouch.c:437 +#, c-format +msgid "debug: calculated max lines %d \n" +msgstr "" + +#: src/libptouch.c:444 #, c-format msgid "debug: called ptouch_get_tape_width() with NULL ptdev\n" msgstr "" -#: src/libptouch.c:424 +#: src/libptouch.c:453 #, c-format msgid "debug: called ptouch_get_max_width() with NULL ptdev\n" msgstr "" -#: src/libptouch.c:436 +#: src/libptouch.c:465 #, c-format msgid "debug: called ptouch_sendraster() with NULL ptdev\n" msgstr "" -#: src/ptouch-print.c:153 +#: src/ptouch-print.c:174 #, c-format msgid "nothing to print\n" msgstr "" -#: src/ptouch-print.c:161 +#: src/ptouch-print.c:182 #, c-format msgid "image is too large (%ipx x %ipx)\n" msgstr "image is too large (%ipx x %ipx)\n" -#: src/ptouch-print.c:162 +#: src/ptouch-print.c:183 #, 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:165 +#: src/ptouch-print.c:186 #, fuzzy, c-format msgid "image size (%ipx x %ipx)\n" msgstr "image is too large (%ipx x %ipx)\n" -#: src/ptouch-print.c:175 +#: src/ptouch-print.c:196 #, c-format msgid "ptouch_rasterstart() failed\n" msgstr "ptouch_rasterstart() failed\n" -#: src/ptouch-print.c:181 +#: src/ptouch-print.c:202 #, c-format msgid "send print information command\n" msgstr "" -#: src/ptouch-print.c:187 +#: src/ptouch-print.c:208 #, c-format msgid "send PT-D460BT magic commands\n" msgstr "" -#: src/ptouch-print.c:194 +#: src/ptouch-print.c:215 #, c-format msgid "send precut command\n" msgstr "" -#: src/ptouch-print.c:203 +#: src/ptouch-print.c:224 #, c-format msgid "send PT-D460BT chain commands\n" msgstr "" -#: src/ptouch-print.c:215 +#: src/ptouch-print.c:236 #, c-format msgid "ptouch_sendraster() failed\n" msgstr "ptouch_sendraster() failed\n" -#: src/ptouch-print.c:264 +#: src/ptouch-print.c:285 #, c-format msgid "writing image '%s' failed\n" msgstr "writing image '%s' failed\n" -#: src/ptouch-print.c:286 +#: src/ptouch-print.c:291 #, c-format -msgid "debug: o baseline offset - %d\n" +msgid "printing '%s' requires %.1f mm of tape\n" msgstr "" -#: src/ptouch-print.c:287 +#: src/ptouch-print.c:313 +#, c-format +msgid "debug: z baseline offset - %d\n" +msgstr "" + +#: src/ptouch-print.c:314 #, c-format msgid "debug: text baseline offset - %d\n" msgstr "" -#: src/ptouch-print.c:346 +#: src/ptouch-print.c:387 #, c-format msgid "render_text(): %i lines, font = '%s', align = '%c'\n" msgstr "" -#: src/ptouch-print.c:349 +#: src/ptouch-print.c:390 #, c-format msgid "warning: font config not available\n" msgstr "warning: font config not available\n" -#: src/ptouch-print.c:353 +#: src/ptouch-print.c:394 #, c-format msgid "setting font size=%i\n" msgstr "setting font size=%i\n" -#: src/ptouch-print.c:357 +#: src/ptouch-print.c:396 +#, fuzzy, c-format +msgid "ignoring setting font margin=%i\n" +msgstr "setting font size=%i\n" + +#: src/ptouch-print.c:401 #, c-format msgid "could not estimate needed font size\n" msgstr "could not estimate needed font size\n" -#: src/ptouch-print.c:364 +#: src/ptouch-print.c:408 #, c-format msgid "choosing font size=%i\n" msgstr "choosing font size=%i\n" -#: src/ptouch-print.c:380 src/ptouch-print.c:414 -#, c-format -msgid "error in gdImageStringFT: %s\n" +#: src/ptouch-print.c:424 src/ptouch-print.c:458 +#, fuzzy, c-format +msgid "error in gdImageStringFT_180dpi: %s\n" msgstr "error in gdImageStringFT: %s\n" -#: src/ptouch-print.c:571 +#: src/ptouch-print.c:615 #, c-format msgid "Only up to %d lines are supported" msgstr "" -#: src/ptouch-print.c:649 +#: src/ptouch-print.c:696 msgid "No arguments supported" msgstr "" -#: src/ptouch-print.c:654 +#: src/ptouch-print.c:701 msgid "Option --writepng missing" msgstr "" -#: src/ptouch-print.c:657 +#: src/ptouch-print.c:704 msgid "Options --force_tape_width and --info can't be used together" msgstr "" -#: src/ptouch-print.c:688 +#: src/ptouch-print.c:735 #, c-format msgid "ptouch_init() failed\n" msgstr "ptouch_init() failed\n" -#: src/ptouch-print.c:691 +#: src/ptouch-print.c:738 #, c-format msgid "ptouch_getstatus() failed\n" msgstr "ptouch_getstatus() failed\n" -#: src/ptouch-print.c:705 +#: 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" msgstr "maximum printing width for this tape is %ipx\n" -#: src/ptouch-print.c:706 +#: src/ptouch-print.c:754 #, 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:731 +#: src/ptouch-print.c:779 #, c-format msgid "failed to load image file\n" msgstr "" -#: src/ptouch-print.c:740 +#: src/ptouch-print.c:788 #, c-format msgid "could not render text\n" msgstr "could not render text\n" -#: src/ptouch-print.c:779 +#: src/ptouch-print.c:827 #, 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 d1ed231..8a9a125 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-06 08:13+0100\n" +"POT-Creation-Date: 2026-03-08 10:24+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:405 +#: src/libptouch.c:369 src/libptouch.c:407 #, c-format msgid "read error: %s\n" msgstr "" @@ -108,194 +108,229 @@ msgstr "" msgid "timeout (%i sec) while waiting for status response\n" msgstr "" -#: src/libptouch.c:388 +#: src/libptouch.c:390 #, c-format msgid "unknown tape width of %imm, please report this.\n" msgstr "" -#: src/libptouch.c:394 +#: src/libptouch.c:396 #, c-format msgid "got only 16 bytes... wondering what they are:\n" msgstr "" -#: src/libptouch.c:398 +#: src/libptouch.c:400 #, c-format msgid "read error: got %i instead of 32 bytes\n" msgstr "" -#: src/libptouch.c:401 +#: src/libptouch.c:403 #, c-format msgid "strange status:\n" msgstr "" -#: src/libptouch.c:403 +#: src/libptouch.c:405 #, c-format msgid "trying to flush junk\n" msgstr "" -#: src/libptouch.c:408 +#: src/libptouch.c:410 #, c-format msgid "got another %i bytes. now try again\n" msgstr "" -#: src/libptouch.c:415 +#: src/libptouch.c:417 +#, c-format +msgid "debug: called ptouch_get_dpi() 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" +msgstr "" + +#: src/libptouch.c:444 #, c-format msgid "debug: called ptouch_get_tape_width() with NULL ptdev\n" msgstr "" -#: src/libptouch.c:424 +#: src/libptouch.c:453 #, c-format msgid "debug: called ptouch_get_max_width() with NULL ptdev\n" msgstr "" -#: src/libptouch.c:436 +#: src/libptouch.c:465 #, c-format msgid "debug: called ptouch_sendraster() with NULL ptdev\n" msgstr "" -#: src/ptouch-print.c:153 +#: src/ptouch-print.c:174 #, c-format msgid "nothing to print\n" msgstr "" -#: src/ptouch-print.c:161 +#: src/ptouch-print.c:182 #, c-format msgid "image is too large (%ipx x %ipx)\n" msgstr "" -#: src/ptouch-print.c:162 +#: src/ptouch-print.c:183 #, c-format msgid "maximum printing width for this tape is %ipx\n" msgstr "" -#: src/ptouch-print.c:165 +#: src/ptouch-print.c:186 #, c-format msgid "image size (%ipx x %ipx)\n" msgstr "" -#: src/ptouch-print.c:175 +#: src/ptouch-print.c:196 #, c-format msgid "ptouch_rasterstart() failed\n" msgstr "" -#: src/ptouch-print.c:181 +#: src/ptouch-print.c:202 #, c-format msgid "send print information command\n" msgstr "" -#: src/ptouch-print.c:187 +#: src/ptouch-print.c:208 #, c-format msgid "send PT-D460BT magic commands\n" msgstr "" -#: src/ptouch-print.c:194 +#: src/ptouch-print.c:215 #, c-format msgid "send precut command\n" msgstr "" -#: src/ptouch-print.c:203 +#: src/ptouch-print.c:224 #, c-format msgid "send PT-D460BT chain commands\n" msgstr "" -#: src/ptouch-print.c:215 +#: src/ptouch-print.c:236 #, c-format msgid "ptouch_sendraster() failed\n" msgstr "" -#: src/ptouch-print.c:264 +#: src/ptouch-print.c:285 #, c-format msgid "writing image '%s' failed\n" msgstr "" -#: src/ptouch-print.c:286 +#: src/ptouch-print.c:291 #, c-format -msgid "debug: o baseline offset - %d\n" +msgid "printing '%s' requires %.1f mm of tape\n" msgstr "" -#: src/ptouch-print.c:287 +#: src/ptouch-print.c:313 +#, c-format +msgid "debug: z baseline offset - %d\n" +msgstr "" + +#: src/ptouch-print.c:314 #, c-format msgid "debug: text baseline offset - %d\n" msgstr "" -#: src/ptouch-print.c:346 +#: src/ptouch-print.c:387 #, c-format msgid "render_text(): %i lines, font = '%s', align = '%c'\n" msgstr "" -#: src/ptouch-print.c:349 +#: src/ptouch-print.c:390 #, c-format msgid "warning: font config not available\n" msgstr "" -#: src/ptouch-print.c:353 +#: src/ptouch-print.c:394 #, c-format msgid "setting font size=%i\n" msgstr "" -#: src/ptouch-print.c:357 +#: src/ptouch-print.c:396 +#, c-format +msgid "ignoring setting font margin=%i\n" +msgstr "" + +#: src/ptouch-print.c:401 #, c-format msgid "could not estimate needed font size\n" msgstr "" -#: src/ptouch-print.c:364 +#: src/ptouch-print.c:408 #, c-format msgid "choosing font size=%i\n" msgstr "" -#: src/ptouch-print.c:380 src/ptouch-print.c:414 +#: src/ptouch-print.c:424 src/ptouch-print.c:458 #, c-format -msgid "error in gdImageStringFT: %s\n" +msgid "error in gdImageStringFT_180dpi: %s\n" msgstr "" -#: src/ptouch-print.c:571 +#: src/ptouch-print.c:615 #, c-format msgid "Only up to %d lines are supported" msgstr "" -#: src/ptouch-print.c:649 +#: src/ptouch-print.c:696 msgid "No arguments supported" msgstr "" -#: src/ptouch-print.c:654 +#: src/ptouch-print.c:701 msgid "Option --writepng missing" msgstr "" -#: src/ptouch-print.c:657 +#: src/ptouch-print.c:704 msgid "Options --force_tape_width and --info can't be used together" msgstr "" -#: src/ptouch-print.c:688 +#: src/ptouch-print.c:735 #, c-format msgid "ptouch_init() failed\n" msgstr "" -#: src/ptouch-print.c:691 +#: src/ptouch-print.c:738 #, c-format msgid "ptouch_getstatus() failed\n" msgstr "" -#: src/ptouch-print.c:705 +#: 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" msgstr "" -#: src/ptouch-print.c:706 +#: src/ptouch-print.c:754 #, c-format msgid "maximum printing width for this tape is %ldpx\n" msgstr "" -#: src/ptouch-print.c:731 +#: src/ptouch-print.c:779 #, c-format msgid "failed to load image file\n" msgstr "" -#: src/ptouch-print.c:740 +#: src/ptouch-print.c:788 #, c-format msgid "could not render text\n" msgstr "" -#: src/ptouch-print.c:779 +#: src/ptouch-print.c:827 #, c-format msgid "ptouch_finalize(%d) failed\n" msgstr "" diff --git a/src/libptouch.c b/src/libptouch.c index f422a0b..81b81d4 100644 --- a/src/libptouch.c +++ b/src/libptouch.c @@ -381,6 +381,8 @@ int ptouch_getstatus(ptouch_dev ptdev, int timeout) 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; } } @@ -409,6 +411,33 @@ int ptouch_getstatus(ptouch_dev ptdev, int timeout) return -1; } +int ptouch_get_dpi(ptouch_dev ptdev) +{ + if (!ptdev) { + fprintf(stderr, _("debug: called ptouch_get_dpi() with NULL ptdev\n")); + return 0; + } + return ptdev->devinfo->dpi; +} + +/* 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 + tape_width in px */ +int ptouch_get_max_lines(ptouch_dev ptdev, int fontsize_px) +{ + if (!ptdev) { + fprintf(stderr, _("debug: called ptouch_get_max_lines() with NULL ptdev\n")); + return 0; + } + if (fontsize_px <= 0) { + fprintf(stderr, _("debug: called ptouch_get_max_lines() with invalid fontsize_px\n")); + return 0; + } + fprintf(stderr, _("debug: calculated max lines %d \n"), ptdev->tape_width_px / fontsize_px); + return 4; +} + size_t ptouch_get_tape_width(ptouch_dev ptdev) { if (!ptdev) { diff --git a/src/ptouch-print.c b/src/ptouch-print.c index 0e4930f..4487e15 100644 --- a/src/ptouch-print.c +++ b/src/ptouch-print.c @@ -35,7 +35,7 @@ #define _(s) gettext(s) -#define MAX_LINES 4 /* maybe this should depend on tape size */ +#define MAX_LINES 4 /* this should be calculated depending on tape size */ #define P_NAME "ptouch-print" @@ -56,6 +56,7 @@ struct arguments { int verbose; int timeout; }; + typedef enum { JOB_CUTMARK, JOB_IMAGE, JOB_PAD, JOB_TEXT, JOB_UNDEFINED } job_type_t; typedef struct job { @@ -91,7 +92,8 @@ static struct argp_option options[] = { { "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}, - { "writepng", 5, "", 0, "Instead of printing, write output to png ", 1}, + { "write-png", 5, "", 0, "Instead of printing, write output to png ", 1}, + { "writepng", 5, "", 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}, @@ -298,7 +300,11 @@ int get_baselineoffset(char *text, char *font, int fsz) { int brect[8]; - /* NOTE: This assumes that 'z' is always on the baseline */ + /* NOTE: This assumes that 'z' is on the baseline for the selected font. + 'z' was choosen instead of 'o' because letters withstraight baseline + are the better choice for the majority of fonts here. + If this makes problems with non-latin fonts with lots of vertically + protruding serifs or decorations, change 'z' to 'o' */ gdImageStringFT_180dpi(NULL, &brect[0], -1, font, fsz, 0.0, 0, 0, "z"); int z_offset = brect[1]; gdImageStringFT_180dpi(NULL, &brect[0], -1, font, fsz, 0.0, 0, 0, text); @@ -743,6 +749,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(_("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));