From b904e22cf19bdb5cf344dc04a14fb712291c254e Mon Sep 17 00:00:00 2001 From: Dominic Radermacher Date: Sun, 11 Aug 2024 13:15:22 +0200 Subject: [PATCH] Add --force-tape-with, enables use of --writepng without the need of a printer connected (thanks to Didi Kohen) --- src/ptouch-print.c | 68 ++++++++++++++++++++++++++++++---------------- 1 file changed, 45 insertions(+), 23 deletions(-) diff --git a/src/ptouch-print.c b/src/ptouch-print.c index b0cbd3e..832b7bf 100644 --- a/src/ptouch-print.c +++ b/src/ptouch-print.c @@ -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-2024 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 @@ -50,14 +50,15 @@ void unsupported_printer(ptouch_dev ptdev); void usage(char *progname); int parse_args(int argc, char **argv); -// char *font_file="/usr/share/fonts/TTF/Ubuntu-M.ttf"; -// char *font_file="Ubuntu:medium"; -char *font_file="DejaVuSans"; -char *save_png=NULL; -int verbose=0; -int fontsize=0; -bool debug=false; -bool chain=false; +// char *font_file = "/usr/share/fonts/TTF/Ubuntu-M.ttf"; +// char *font_file = "Ubuntu:medium"; +char *font_file = "DejaVuSans"; +char *save_png = NULL; +int verbose = 0; +int fontsize = 0; +bool debug = false; +bool chain = false; +int forced_tape_width = 0; /* -------------------------------------------------------------------- -------------------------------------------------------------------- */ @@ -422,6 +423,8 @@ void usage(char *progname) printf("\t--font \t\tuse font or \n"); printf("\t--fontsize \tManually set fontsize\n"); printf("\t--writepng \tinstead of printing, write output to png file\n"); + printf("\t--force-tape-width \tSet tape width in pixels, use together with\n"); + printf("\t\t\t\t--writepng without a printer connected.\n"); printf("print commands:\n"); printf("\t--image \t\tprint the given image which must be a 2 color\n"); printf("\t\t\t\t(black/white) png\n"); @@ -464,6 +467,12 @@ int parse_args(int argc, char **argv) } else { usage(argv[0]); } + } else if (strcmp(&argv[i][1], "-force-tape-width") == 0) { + if (i+1status->media_type, pt_mediatype(ptdev->status->media_type)); @@ -622,7 +642,9 @@ int main(int argc, char *argv[]) if (im != NULL) { gdImageDestroy(im); } - ptouch_close(ptdev); + if (forced_tape_width > 0) { + ptouch_close(ptdev); + } libusb_exit(NULL); return 0; }