mirror of
https://git.familie-radermacher.ch/linux/ptouch-print.git
synced 2025-06-28 03:57:02 +00:00
Add --force-tape-with, enables use of --writepng without the need of a printer connected (thanks to Didi Kohen)
This commit is contained in:
parent
da9ed2600a
commit
b904e22cf1
@ -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-2023 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
|
||||||
@ -50,14 +50,15 @@ void unsupported_printer(ptouch_dev ptdev);
|
|||||||
void usage(char *progname);
|
void usage(char *progname);
|
||||||
int parse_args(int argc, char **argv);
|
int parse_args(int argc, char **argv);
|
||||||
|
|
||||||
// char *font_file="/usr/share/fonts/TTF/Ubuntu-M.ttf";
|
// char *font_file = "/usr/share/fonts/TTF/Ubuntu-M.ttf";
|
||||||
// char *font_file="Ubuntu:medium";
|
// char *font_file = "Ubuntu:medium";
|
||||||
char *font_file="DejaVuSans";
|
char *font_file = "DejaVuSans";
|
||||||
char *save_png=NULL;
|
char *save_png = NULL;
|
||||||
int verbose=0;
|
int verbose = 0;
|
||||||
int fontsize=0;
|
int fontsize = 0;
|
||||||
bool debug=false;
|
bool debug = false;
|
||||||
bool chain=false;
|
bool chain = false;
|
||||||
|
int forced_tape_width = 0;
|
||||||
|
|
||||||
/* --------------------------------------------------------------------
|
/* --------------------------------------------------------------------
|
||||||
-------------------------------------------------------------------- */
|
-------------------------------------------------------------------- */
|
||||||
@ -422,6 +423,8 @@ void usage(char *progname)
|
|||||||
printf("\t--font <file>\t\tuse font <file> or <name>\n");
|
printf("\t--font <file>\t\tuse font <file> or <name>\n");
|
||||||
printf("\t--fontsize <size>\tManually set fontsize\n");
|
printf("\t--fontsize <size>\tManually set fontsize\n");
|
||||||
printf("\t--writepng <file>\tinstead of printing, write output to png file\n");
|
printf("\t--writepng <file>\tinstead of printing, write output to png file\n");
|
||||||
|
printf("\t--force-tape-width <px>\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("print commands:\n");
|
||||||
printf("\t--image <file>\t\tprint the given image which must be a 2 color\n");
|
printf("\t--image <file>\t\tprint the given image which must be a 2 color\n");
|
||||||
printf("\t\t\t\t(black/white) png\n");
|
printf("\t\t\t\t(black/white) png\n");
|
||||||
@ -464,6 +467,12 @@ int parse_args(int argc, char **argv)
|
|||||||
} else {
|
} else {
|
||||||
usage(argv[0]);
|
usage(argv[0]);
|
||||||
}
|
}
|
||||||
|
} else if (strcmp(&argv[i][1], "-force-tape-width") == 0) {
|
||||||
|
if (i+1<argc) {
|
||||||
|
forced_tape_width=strtol(argv[++i], NULL, 10);
|
||||||
|
} else {
|
||||||
|
usage(argv[0]);
|
||||||
|
}
|
||||||
} else if (strcmp(&argv[i][1], "-cutmark") == 0) {
|
} else if (strcmp(&argv[i][1], "-cutmark") == 0) {
|
||||||
continue; /* not done here */
|
continue; /* not done here */
|
||||||
} else if (strcmp(&argv[i][1], "-chain") == 0) {
|
} else if (strcmp(&argv[i][1], "-chain") == 0) {
|
||||||
@ -501,6 +510,9 @@ int parse_args(int argc, char **argv)
|
|||||||
usage(argv[0]);
|
usage(argv[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (forced_tape_width && !save_png) {
|
||||||
|
forced_tape_width = 0;
|
||||||
|
}
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -519,6 +531,7 @@ int main(int argc, char *argv[])
|
|||||||
if (i != argc) {
|
if (i != argc) {
|
||||||
usage(argv[0]);
|
usage(argv[0]);
|
||||||
}
|
}
|
||||||
|
if (!forced_tape_width) {
|
||||||
if ((ptouch_open(&ptdev)) < 0) {
|
if ((ptouch_open(&ptdev)) < 0) {
|
||||||
return 5;
|
return 5;
|
||||||
}
|
}
|
||||||
@ -530,6 +543,9 @@ int main(int argc, char *argv[])
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
tape_width=ptouch_get_tape_width(ptdev);
|
tape_width=ptouch_get_tape_width(ptdev);
|
||||||
|
} else {
|
||||||
|
tape_width = forced_tape_width;
|
||||||
|
}
|
||||||
for (i=1; i<argc; ++i) {
|
for (i=1; i<argc; ++i) {
|
||||||
if (*argv[i] != '-') {
|
if (*argv[i] != '-') {
|
||||||
break;
|
break;
|
||||||
@ -546,12 +562,16 @@ int main(int argc, char *argv[])
|
|||||||
} else {
|
} else {
|
||||||
usage(argv[0]);
|
usage(argv[0]);
|
||||||
}
|
}
|
||||||
} else if (strcmp(&argv[i][1], "-writepng") == 0) {
|
} else if (strcmp(&argv[i][1], "-force-tape-width") == 0) {
|
||||||
if (i+1<argc) {
|
if (forced_tape_width && save_png) {
|
||||||
save_png=argv[++i];
|
++i;
|
||||||
|
continue;
|
||||||
} else {
|
} else {
|
||||||
usage(argv[0]);
|
usage(argv[0]);
|
||||||
}
|
}
|
||||||
|
} else if (strcmp(&argv[i][1], "-writepng") == 0) {
|
||||||
|
i++;
|
||||||
|
continue;
|
||||||
} else if (strcmp(&argv[i][1], "-info") == 0) {
|
} else if (strcmp(&argv[i][1], "-info") == 0) {
|
||||||
printf(_("maximum printing width for this tape is %ipx\n"), tape_width);
|
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 type = %02x (%s)\n", ptdev->status->media_type, pt_mediatype(ptdev->status->media_type));
|
||||||
@ -622,7 +642,9 @@ int main(int argc, char *argv[])
|
|||||||
if (im != NULL) {
|
if (im != NULL) {
|
||||||
gdImageDestroy(im);
|
gdImageDestroy(im);
|
||||||
}
|
}
|
||||||
|
if (forced_tape_width > 0) {
|
||||||
ptouch_close(ptdev);
|
ptouch_close(ptdev);
|
||||||
|
}
|
||||||
libusb_exit(NULL);
|
libusb_exit(NULL);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user